Beispiel #1
0
        private void StateChangedHandler(ProfileSessionState newState)
        {
            _profileSessionState = newState;

            switch (newState)
            {
            case ProfileSessionState.Running:
                Application.Current.Dispatcher.BeginInvoke(new System.Action(() =>
                {
                    // sometimes the window is not visible after Show in SetSession
                    System.Threading.Thread.Sleep(2000);
                    if (_profileSessionState == ProfileSessionState.Running)     // still running?
                    {
                        Show();
                    }
                }));
                break;

            case ProfileSessionState.Failed:
            case ProfileSessionState.Finished:
                _session.RemoveListener(_listener);
                Application.Current.Dispatcher.Invoke(() =>
                {
                    // hide the window and clear the session
                    Hide();
                    ((ProfilingProgressWindowContent)Content).ClearSession();
                    if (newState == ProfileSessionState.Finished)
                    {
                        ProfilerPlugin.Instance.SessionsContainer.Update();
                    }
                });
                break;
            }
        }
Beispiel #2
0
 private void StateChangedHandler(ProfileSessionState newState)
 {
     if (newState == ProfileSessionState.Finished || newState == ProfileSessionState.Failed)
     {
         ProfileSession s = _currentSession;
         _currentSession = null;
         if (s != null)
         {
             s.Destroy();
         }
     }
 }
        private void ProcessStateChange(ProfileSessionState newState)
        {
            _lastSessionState = newState;

            Task.Run(() =>
                     Dispatcher.Invoke(delegate()
            {
                Status.Text = StateToString(newState);
                UpdateSessionControlButton(newState);
            }));

            if (newState >= ProfileSessionState.Finished)
            {
                CloseLog();
            }
        }
        private void UpdateSessionControlButton(ProfileSessionState state)
        {
            string sessionControlContent;

            bool       sessionControlEnabled    = true;
            Visibility sessionControlVisibility = Visibility.Visible;

            bool       sessionStopEnabled    = true;
            Visibility sessionStopVisibility = Visibility.Visible;

            switch (state)
            {
            case ProfileSessionState.Waiting:
                sessionControlContent = StartButtonLabel;
                break;

            case ProfileSessionState.Running:
                sessionControlContent = PauseButtonLabel;
                break;

            case ProfileSessionState.Paused:
                sessionControlContent = ResumeButtonLabel;
                break;

            default:
                sessionControlContent = "";

                sessionControlEnabled    = false;
                sessionControlVisibility = Visibility.Collapsed;

                sessionStopEnabled    = false;
                sessionStopVisibility = Visibility.Collapsed;

                break;
            }

            SessionControlButton.Content = sessionControlContent;

            SessionControlButton.IsEnabled  = sessionControlEnabled;
            SessionControlButton.Visibility = sessionControlVisibility;

            StopButton.IsEnabled  = sessionStopEnabled;
            StopButton.Visibility = sessionStopVisibility;
        }
        private string StateToString(ProfileSessionState state)
        {
            switch (state)
            {
            case ProfileSessionState.Initial:
                return("Initial");

            case ProfileSessionState.Starting:
                return("Starting");

            case ProfileSessionState.UploadFiles:
                return("Upload Files");

            case ProfileSessionState.StartHost:
                return("Starting Host");

            case ProfileSessionState.Waiting:
                return("Waiting");

            case ProfileSessionState.Running:
                return("Running");

            case ProfileSessionState.Paused:
                return("Paused");

            case ProfileSessionState.Stopping:
                return("Stopping");

            case ProfileSessionState.DownloadFiles:
                return("Download Files");

            case ProfileSessionState.WritingSession:
                return("Writing Session");

            case ProfileSessionState.Finished:
                return("Finished");

            case ProfileSessionState.Failed:
                return("Failed");

            default:
                return("<Unknown>");
            }
        }