public void Close()
 {
     this.availableBookmarks            = null;
     this.CanResumeBookmarks            = false;
     this.instance.Aborted              = null;
     this.instance.Completed            = null;
     this.instance.Idle                 = null;
     this.instance.OnUnhandledException = null;
     this.instance.Unloaded             = null;
     this.applicationHandler            = null;
     this.isLoaded = false;
 }
        public WorkflowApplicationState(WorkflowApplication instance, IWorkflowApplicationHandler applicationHandler, TextWriter instanceWriter)
        {
            this.instance = instance;
            this.applicationHandler = applicationHandler;
            this.isLoaded = true;

            this.instanceWriter = instanceWriter;

            try
            {
                this.availableBookmarks = this.instance.GetBookmarks();
            }
            catch (WorkflowApplicationException)
            {
                //it is possible the instance completed through some other stimulus (ex. load);
            }

            instance.Aborted = new Action<WorkflowApplicationAbortedEventArgs>(applicationHandler.OnAborted);
            instance.Completed = new Action<WorkflowApplicationCompletedEventArgs>(applicationHandler.OnCompleted);
            instance.Idle = new Action<WorkflowApplicationIdleEventArgs>(OnIdle);
            instance.OnUnhandledException = new Func<WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction>(applicationHandler.OnUnhandledException);
            instance.Unloaded = new Action<WorkflowApplicationEventArgs>(OnUnloaded);
        }
        public WorkflowApplicationState(WorkflowApplication instance, IWorkflowApplicationHandler applicationHandler, TextWriter instanceWriter)
        {
            this.instance           = instance;
            this.applicationHandler = applicationHandler;
            this.isLoaded           = true;

            this.instanceWriter = instanceWriter;

            try
            {
                this.availableBookmarks = this.instance.GetBookmarks();
            }
            catch (WorkflowApplicationException)
            {
                //it is possible the instance completed through some other stimulus (ex. load);
            }

            instance.Aborted              = new Action <WorkflowApplicationAbortedEventArgs>(applicationHandler.OnAborted);
            instance.Completed            = new Action <WorkflowApplicationCompletedEventArgs>(applicationHandler.OnCompleted);
            instance.Idle                 = new Action <WorkflowApplicationIdleEventArgs>(OnIdle);
            instance.OnUnhandledException = new Func <WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction>(applicationHandler.OnUnhandledException);
            instance.Unloaded             = new Action <WorkflowApplicationEventArgs>(OnUnloaded);
        }
 public void Close()
 {
     this.availableBookmarks = null;
     this.CanResumeBookmarks = false;
     this.instance.Aborted = null;
     this.instance.Completed = null;
     this.instance.Idle = null;
     this.instance.OnUnhandledException = null;
     this.instance.Unloaded = null;
     this.applicationHandler = null;
     this.isLoaded = false;
 }