public void UpdateInstances(List <WorkflowApplicationInfo> instanceInfos)
        {
            this.Dispatcher.BeginInvoke(
                new Action(() =>
            {
                WorkflowApplicationInfo originalApplicationInfo = CurrentWorkflowApplicationInfo;
                BookmarkInfo originalBookmarkInfo = this.bookmarksComboBox.SelectedItem as BookmarkInfo;

                this.instanceInfos = instanceInfos;
                this.DataContext   = this.instanceInfos;

                if (originalApplicationInfo != null)
                {
                    originalApplicationInfo = this.instanceInfos.Find(applicationInfo => applicationInfo.Id == originalApplicationInfo.Id);
                    if (originalApplicationInfo != null && this.defaultView != null)
                    {
                        this.defaultView.MoveCurrentTo(originalApplicationInfo);
                    }
                    if (originalBookmarkInfo != null)
                    {
                        BookmarkInfo newBookmarkInfo = this.bookmarksComboBox.Items.Cast <BookmarkInfo>().FirstOrDefault(
                            (bookmarkInfo) => bookmarkInfo.BookmarkName == originalBookmarkInfo.BookmarkName);
                        if (newBookmarkInfo != null)
                        {
                            this.bookmarksComboBox.SelectedItem = newBookmarkInfo;
                        }
                    }
                }
            }), DispatcherPriority.DataBind);
        }
        void OnCurrentChanged(object sender, EventArgs e)
        {
            WorkflowApplicationInfo currentApplicationInfo = CurrentWorkflowApplicationInfo;

            if (currentApplicationInfo != null)
            {
                this.instanceOutputTextBox.Text = currentApplicationInfo.InstanceWriter.ToString();
            }
            SetUiState();
        }
        void OnResumeBookmarkButtonClicked(object sender, RoutedEventArgs e)
        {
            WorkflowApplicationInfo applicationInfo = this.CurrentWorkflowApplicationInfo;
            BookmarkInfo            bookmarkInfo    = this.bookmarksComboBox.SelectedItem as BookmarkInfo;

            if (applicationInfo != null && bookmarkInfo != null)
            {
                this.manager.ResumeBookmark(applicationInfo.Id, bookmarkInfo.BookmarkName, this.bookmarkValueTextBox.Text);
            }
            this.bookmarkValueTextBox.Text = string.Empty;
        }
        void SetUiState()
        {
            if (this.IsInitialized)
            {
                WorkflowApplicationInfo currentApplicationInfo = CurrentWorkflowApplicationInfo;
                bool currentApplicationInfoIsNull   = currentApplicationInfo == null;
                bool currentApplicationInfoIsLoaded = !currentApplicationInfoIsNull && currentApplicationInfo.IsLoaded;

                this.abortButton.IsEnabled     = currentApplicationInfoIsLoaded;
                this.cancelButton.IsEnabled    = currentApplicationInfoIsLoaded;
                this.terminateButton.IsEnabled = currentApplicationInfoIsLoaded;
                SetResumeBookmarkButtonState();
            }
        }
        void OnAbortButtonClicked(object sender, RoutedEventArgs e)
        {
            WorkflowApplicationInfo applicationInfo = this.CurrentWorkflowApplicationInfo;

            this.manager.Abort(applicationInfo.Id, "User requested Abort");
        }
        void OnTerminateButtonClicked(object sender, RoutedEventArgs e)
        {
            WorkflowApplicationInfo applicationInfo = this.CurrentWorkflowApplicationInfo;

            this.manager.Terminate(applicationInfo.Id, "User initiated Terminate");
        }
        void OnCancelButtonClicked(object sender, RoutedEventArgs e)
        {
            WorkflowApplicationInfo applicationInfo = this.CurrentWorkflowApplicationInfo;

            this.manager.Cancel(applicationInfo.Id);
        }