当前位置: 首页>>代码示例>>C#>>正文


C# ActivityExecutionContext.Invoke方法代码示例

本文整理汇总了C#中ActivityExecutionContext.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# ActivityExecutionContext.Invoke方法的具体用法?C# ActivityExecutionContext.Invoke怎么用?C# ActivityExecutionContext.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActivityExecutionContext的用法示例。


在下文中一共展示了ActivityExecutionContext.Invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RevertToCheckpointState

 internal void RevertToCheckpointState()
 {
     Activity rootActivity = null;
     this.clonedInstanceStateStream.Position = 0L;
     using (new RuntimeEnvironment(this.workflowExecutor.WorkflowRuntime))
     {
         rootActivity = Activity.Load(this.clonedInstanceStateStream, this.workflowDefinition);
     }
     rootActivity.SetValue(WorkflowExecutor.TrackingListenerBrokerProperty, this.workflowExecutor.RootActivity.GetValue(WorkflowExecutor.TrackingListenerBrokerProperty));
     WorkflowExecutor newWorkflowExecutor = new WorkflowExecutor(Guid.Empty);
     newWorkflowExecutor.Initialize(rootActivity, this.workflowExecutor.WorkflowRuntime, this.workflowExecutor);
     Activity contextActivityForId = newWorkflowExecutor.GetContextActivityForId(this.activityContextId);
     Activity activityByName = contextActivityForId.GetActivityByName(this.activityQualifiedName);
     using (new ServiceEnvironment(activityByName))
     {
         using (newWorkflowExecutor.SetCurrentActivity(activityByName))
         {
             using (ActivityExecutionContext context = new ActivityExecutionContext(activityByName))
             {
                 context.Invoke<EventArgs>(this.callbackHandler, this.callbackData);
             }
         }
     }
     newWorkflowExecutor.BatchCollection.WorkItemOrderId = this.workflowExecutor.BatchCollection.WorkItemOrderId;
     foreach (KeyValuePair<object, WorkBatch> pair in this.workflowExecutor.BatchCollection)
     {
         pair.Value.SetWorkBatchCollection(newWorkflowExecutor.BatchCollection);
         Activity key = pair.Key as Activity;
         if (key != null)
         {
             Activity activity5 = contextActivityForId.GetActivityByName(key.QualifiedName);
             newWorkflowExecutor.BatchCollection.Add(activity5, pair.Value);
         }
     }
     this.workflowExecutor.BatchCollection.Clear();
     newWorkflowExecutor.CompletedContextActivities = this.completedContextActivities;
     this.workflowExecutor.WorkflowRuntime.ReplaceWorkflowExecutor(this.workflowExecutor.InstanceId, this.workflowExecutor, newWorkflowExecutor);
     if (!this.suspendOnRevert)
     {
         newWorkflowExecutor.Scheduler.Resume();
     }
     else
     {
         newWorkflowExecutor.SuspendOnIdle(this.suspendOnRevertInfo);
     }
     this.DisposeCheckpointState();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:47,代码来源:WorkflowStateRollbackService.cs

示例2: RevertToCheckpointState

        internal void RevertToCheckpointState()
        {
            Debug.Assert(this.clonedInstanceStateStream != null, "cloned instance-state stream null at restore time");

            // deserialize only on first access
            Activity clonedRootActivity = null;
            this.clonedInstanceStateStream.Position = 0;
            using (RuntimeEnvironment runtimeEnv = new RuntimeEnvironment(this.workflowExecutor.WorkflowRuntime))
            {
                clonedRootActivity = Activity.Load(this.clonedInstanceStateStream, (Activity)this.workflowDefinition);
            }
            Debug.Assert(clonedRootActivity != null);
            //
            // Set the trackingListenerBroker before initializing the executor so the tracking
            // runtime gets a reference to the correct object
            clonedRootActivity.SetValue(WorkflowExecutor.TrackingListenerBrokerProperty, workflowExecutor.RootActivity.GetValue(WorkflowExecutor.TrackingListenerBrokerProperty));

            // create the new workflowExecutor
            WorkflowExecutor newWorkflowExecutor = new WorkflowExecutor(Guid.Empty);    // use a dummy guid while swapping executors
            newWorkflowExecutor.Initialize(clonedRootActivity, this.workflowExecutor.WorkflowRuntime, this.workflowExecutor);

            // enqueue the activity notifier
            Activity activityContext = newWorkflowExecutor.GetContextActivityForId(this.activityContextId);
            Activity activity = activityContext.GetActivityByName(this.activityQualifiedName);
            using (new ServiceEnvironment(activity))
            {
                using (newWorkflowExecutor.SetCurrentActivity(activity))
                {
                    using (ActivityExecutionContext executionContext = new ActivityExecutionContext(activity))
                        executionContext.Invoke<EventArgs>(this.callbackHandler, this.callbackData);
                }
            }
            //
            // Push the batch item ordering id to the new instance
            newWorkflowExecutor.BatchCollection.WorkItemOrderId = this.workflowExecutor.BatchCollection.WorkItemOrderId;
            // replace pending batch items
            foreach (KeyValuePair<object, WorkBatch> batch in this.workflowExecutor.BatchCollection)
            {
                batch.Value.SetWorkBatchCollection(newWorkflowExecutor.BatchCollection);
                Activity oldActivity = batch.Key as Activity;
                // no need to add the transient state batch
                if (oldActivity != null)
                {
                    Activity newactivity = activityContext.GetActivityByName(oldActivity.QualifiedName);
                    newWorkflowExecutor.BatchCollection.Add(newactivity, batch.Value);
                }
            }
            this.workflowExecutor.BatchCollection.Clear();

            Debug.Assert(this.completedContextActivities != null);
            newWorkflowExecutor.CompletedContextActivities = this.completedContextActivities;

            // replace with the WorkflowRuntime
            Debug.Assert(this.workflowExecutor.IsInstanceValid);
            this.workflowExecutor.WorkflowRuntime.ReplaceWorkflowExecutor(this.workflowExecutor.InstanceId, this.workflowExecutor, newWorkflowExecutor);

            // now resume or suspend the scheduler as needed
            if (!this.suspendOnRevert)
            {
                // get the new one going
                newWorkflowExecutor.Scheduler.Resume();
            }
            else
            {
                // this call will be old scheduler's thread
                newWorkflowExecutor.SuspendOnIdle(this.suspendOnRevertInfo);
            }
            DisposeCheckpointState();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:69,代码来源:WorkflowStateRollbackService.cs


注:本文中的ActivityExecutionContext.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。