コード例 #1
0
        }//buttonExit_Click()

        /// <summary>
        /// Form closing event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AmbreRecoveryViewer_Closing(object sender, FormClosingEventArgs e)
        {
            // Exit.
            this.FormClosing -= new FormClosingEventHandler(AmbreRecoveryViewer_Closing);

            // Delete the files we copied.
            if (m_RepoFileList.Count > 0)
            {
                try
                {
                    foreach (string filePath in m_RepoFileList)
                    {
                        System.IO.File.Delete(filePath);
                    }
                }
                catch (Exception ex)
                {
                    Log.NewEntry(LogLevel.Major, "Failed to delete copied files and the error is {0}.", ex);
                }
            }

            // Shut down the fill hub.
            if (m_AuditTrailFillHub != null)
            {
                m_AuditTrailFillHub.RequestSubstractEventHandler();
                m_AuditTrailFillHub.RequestStop();
                m_AuditTrailFillHub = null;
            }

            // Shut down the services.
            if (m_MarketTTAPIService != null)
            {
                m_MarketTTAPIService.RequestStop();
                m_MarketTTAPIService = null;
            }
            if (m_TTAPIService != null)
            {
                m_TTAPIService.ServiceStateChanged -= new EventHandler(TTAPIService_ServiceStateChanged);
                m_TTAPIService.RequestStop();
                m_TTAPIService = null;
            }

            // Shut down the log.
            if (Log != null)
            {
                Log.NewEntry(LogLevel.Minor, "The form is closing.");
                Log.Flush();
                Log.RequestStop();
                Log = null;
            }
        }//Form_Closing()
コード例 #2
0
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        //
        //
        //
        // ****                   ShutDown()                       ****
        //
        /// <summary>
        /// Called when the form is about to close to release resources nicely.
        /// </summary>
        private void ShutDown()
        {
            if (!m_IsAppShuttingDown)
            {
                m_IsAppShuttingDown = true;

                if (Log != null)
                {
                    Log.RequestStop();
                    Log = null;
                }

                if (m_FillHub != null)
                {
                    //m_FillHub.PositionBookCreated -= new EventHandler(FillHub_PositionBookCreated);
                    //m_FillHub.PositionBookChanged -= new EventHandler(FillHub_PositionBookChanged);
                    //m_FillHub.PositionBookPnLChanged -= new EventHandler(FillHub_PositionBookPnLChanged);
                    m_FillHub.Request(new Misty.Lib.OrderHubs.OrderHubRequest(Misty.Lib.OrderHubs.OrderHubRequest.RequestType.RequestShutdown));
                    m_FillHub = null;
                }
                if (m_MarketHub != null)
                {
                    m_MarketHub.RequestStop();
                    m_MarketHub = null;
                }
                if (m_TTServices != null)
                {
                    m_TTServices.ServiceStateChanged -= new EventHandler(TTServices_ServiceStateChanged);
                    m_TTServices.Dispose();
                    m_TTServices = null;
                }
                if (m_TalkerHub != null)
                {
                    m_TalkerHub.ServiceStateChanged -= new EventHandler(TalkerHub_ServiceStateChanged);
                    m_TalkerHub.Request(TalkerHubRequest.StopService);
                    //m_TalkerHub = null;
                }
            }
        }//Shutdown().