예제 #1
0
        /// <summary>
        /// Handle the Form Closed event for the Dashboard Form
        /// </summary>
        /// <param name="onClosed">The closed message</param>
        private void OnClosedHandler(OnClosed onClosed)
        {
            if (onClosed.DashboardForm == this.dashboardForm)
            {
                LogInfo("Form Closed");

                this.mainPort.Post(new DsspDefaultDrop(DropRequestType.Instance));
                ControlPanelPort.Post(new DsspDefaultDrop(DropRequestType.Instance));

                if (this.cameraForm != null)
                {
                    var closeWebcam = new FormInvoke(
                        delegate
                    {
                        this.cameraForm.Close();
                        this.cameraForm = null;
                    });

                    WinFormsServicePort.Post(closeWebcam);
                }

                if (this.depthCameraForm != null)
                {
                    var closeDepthcam = new FormInvoke(
                        delegate
                    {
                        this.depthCameraForm.Close();
                        this.depthCameraForm = null;
                    });

                    WinFormsServicePort.Post(closeDepthcam);
                }
            }
        }
        /// <summary>
        /// Shutdown or kill process
        /// </summary>
        /// <returns>ITask enumerator</returns>
        private IEnumerator <ITask> ShutdownSuccessfullyOrKillProcess()
        {
            var shutdownOrTimedOut = new SuccessFailurePort();

            Activate(TimeoutPort(DefaultProcessTimeout).Receive(dateTime => shutdownOrTimedOut.Post(new Exception())));
            Activate(shutdownOrTimedOut.Choice(
                         success => { }, /*cleanly shutdown*/
                         failure => /*timed out*/ System.Diagnostics.Process.GetCurrentProcess().Kill()));

            ControlPanelPort.Post(new DsspDefaultDrop());
            Activate(Arbiter.ReceiveWithIterator <DsspDefaultDrop>(false, this.mainPort, this.DropHandler));

            shutdownOrTimedOut.Post(SuccessResult.Instance);

            yield break;
        }