本文整理汇总了C#中NativeActivityContext.MarkCanceled方法的典型用法代码示例。如果您正苦于以下问题:C# NativeActivityContext.MarkCanceled方法的具体用法?C# NativeActivityContext.MarkCanceled怎么用?C# NativeActivityContext.MarkCanceled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeActivityContext
的用法示例。
在下文中一共展示了NativeActivityContext.MarkCanceled方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cancel
protected override void Cancel(NativeActivityContext context)
{
Bookmark bookmark = this.timerBookmark.Get(context);
this.GetTimerExtension(context).CancelTimer(bookmark);
context.RemoveBookmark(bookmark);
context.MarkCanceled();
}
示例2: Cancel
protected override void Cancel(NativeActivityContext context)
{
Bookmark bookmark = timerExpiredBookmark.Get(context);
if (bookmark != null)
{
context.GetTimerExtension().CancelTimer(bookmark);
context.RemoveBookmark(bookmark);
}
context.MarkCanceled();
}
示例3: OnBodyComplete
private void OnBodyComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
{
if ((completedInstance.State == ActivityInstanceState.Canceled) || (context.IsCancellationRequested && (completedInstance.State == ActivityInstanceState.Faulted)))
{
this.suppressCancel.Set(context, true);
context.MarkCanceled();
if (this.CancellationHandler != null)
{
FaultCallback onFaulted = new FaultCallback(this.OnExceptionFromCancelHandler);
context.ScheduleActivity(this.CancellationHandler, onFaulted);
}
}
}
示例4: OnBranchComplete
private void OnBranchComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
{
if ((this.CompletionCondition != null) && !this.hasCompleted.Get(context))
{
if ((completedInstance.State != ActivityInstanceState.Closed) && context.IsCancellationRequested)
{
context.MarkCanceled();
this.hasCompleted.Set(context, true);
}
else
{
if (this.onConditionComplete == null)
{
this.onConditionComplete = new CompletionCallback<bool>(this.OnConditionComplete);
}
context.ScheduleActivity<bool>(this.CompletionCondition, this.onConditionComplete, null);
}
}
}
示例5: OnBranchComplete
private void OnBranchComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
{
PickState pickState = this.pickStateVariable.Get(context);
ReadOnlyCollection<System.Activities.ActivityInstance> children = context.GetChildren();
switch (completedInstance.State)
{
case ActivityInstanceState.Closed:
pickState.HasBranchCompletedSuccessfully = true;
break;
case ActivityInstanceState.Canceled:
case ActivityInstanceState.Faulted:
if ((context.IsCancellationRequested && (children.Count == 0)) && !pickState.HasBranchCompletedSuccessfully)
{
context.MarkCanceled();
context.RemoveAllBookmarks();
}
break;
}
if ((children.Count == 1) && (pickState.ExecuteActionBookmark != null))
{
this.ResumeExecutionActionBookmark(pickState, context);
}
}
示例6: Execute
protected override void Execute(NativeActivityContext context)
{
context.MarkCanceled();
}
示例7: Cancel
protected override void Cancel(NativeActivityContext context)
{
context.CancelChildren();
var bookmark = bookmarkProgress.Get(context);
var extension = context.GetExtension<Hosting.FileCopyExtension>();
extension.Cancel(bookmark.Name);
this.noPersistHandle.Get(context).Exit(context);
context.RemoveBookmark(bookmark);
context.MarkCanceled();
}
示例8: OnBranchComplete
void OnBranchComplete(NativeActivityContext context, ActivityInstance completedInstance)
{
if (this.CompletionCondition != null && !this.hasCompleted.Get(context))
{
// If we haven't completed, we've been requested to cancel, and we've had a child
// end in a non-Closed state then we should cancel ourselves.
if (completedInstance.State != ActivityInstanceState.Closed && context.IsCancellationRequested)
{
context.MarkCanceled();
this.hasCompleted.Set(context, true);
return;
}
if (this.onConditionComplete == null)
{
this.onConditionComplete = new CompletionCallback<bool>(OnConditionComplete);
}
context.ScheduleActivity(this.CompletionCondition, this.onConditionComplete);
}
}
示例9: OnBodyComplete
void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance)
{
// for the completion condition, we handle cancelation ourselves
if (this.CompletionCondition != null && !this.hasCompleted.Get(context))
{
if (completedInstance.State != ActivityInstanceState.Closed && context.IsCancellationRequested)
{
// If we hadn't completed before getting canceled
// or one of our iteration of body cancels then we'll consider
// ourself canceled.
context.MarkCanceled();
this.hasCompleted.Set(context, true);
}
else
{
if (this.onConditionComplete == null)
{
this.onConditionComplete = new CompletionCallback<bool>(OnConditionComplete);
}
context.ScheduleActivity(CompletionCondition, this.onConditionComplete);
}
}
}
示例10: InternalExecute
void InternalExecute(NativeActivityContext context, IEnumerator valueEnumerator)
{
if (!valueEnumerator.MoveNext())
{
OnForEachComplete(valueEnumerator);
return;
}
// After making sure there is another value, let's check for cancelation
if (context.IsCancellationRequested)
{
context.MarkCanceled();
OnForEachComplete(valueEnumerator);
return;
}
context.ScheduleAction(this.Body, valueEnumerator.Current, this.OnChildComplete);
}
示例11: OnBodyComplete
void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance)
{
// Determine whether to run the Cancel based on whether the body
// canceled rather than whether cancel had been requested.
if (completedInstance.State == ActivityInstanceState.Canceled ||
(context.IsCancellationRequested && completedInstance.State == ActivityInstanceState.Faulted))
{
// We don't cancel the cancel handler
this.suppressCancel.Set(context, true);
context.MarkCanceled();
if (this.CancellationHandler != null)
{
context.ScheduleActivity(this.CancellationHandler, onFaulted: new FaultCallback(OnExceptionFromCancelHandler));
}
}
}
示例12: Cancel
protected override void Cancel(NativeActivityContext context)
{
var subscriptionHandle = this.SubscriptionHandle.Get(context);
subscriptionHandle.ReleaseSubscription(context.GetExtension<Hosting.FolderWatcherExtension>());
context.RemoveAllBookmarks();
context.MarkCanceled();
}
示例13: Cancel
protected override void Cancel(NativeActivityContext context)
{
try
{
if (this.bookmarking.Get(context))
{
NoPersistHandle noPersistHandle = this.noPersistHandle.Get(context);
noPersistHandle.Enter(context);
}
PSActivityContext item = null;
HostParameterDefaults extension = context.GetExtension<HostParameterDefaults>();
if (extension != null && extension.AsyncExecutionCollection != null)
{
Dictionary<string, PSActivityContext> asyncExecutionCollection = extension.AsyncExecutionCollection;
if (asyncExecutionCollection.ContainsKey(context.ActivityInstanceId))
{
item = asyncExecutionCollection[context.ActivityInstanceId];
asyncExecutionCollection.Remove(context.ActivityInstanceId);
}
}
if (item == null)
{
item = this.psActivityContextImplementationVariable.Get(context);
}
item.IsCanceled = true;
this.psActivityContextImplementationVariable.Set(context, item);
this.Tracer.WriteMessage(string.Format(CultureInfo.InvariantCulture, "PowerShell activity: Executing cancel request.", new object[0]));
if (item.commandQueue != null && !item.commandQueue.IsEmpty)
{
ActivityImplementationContext[] array = item.commandQueue.ToArray();
for (int i = 0; i < (int)array.Length; i++)
{
ActivityImplementationContext activityImplementationContext = array[i];
RunCommandsArguments runCommandsArgument = null;
PSActivity.ArgsTable.TryGetValue(activityImplementationContext.PowerShellInstance.InstanceId, out runCommandsArgument);
if (runCommandsArgument != null)
{
PSActivity.RemoveHandlersFromStreams(activityImplementationContext.PowerShellInstance, runCommandsArgument);
}
}
}
if (item.runningCommands != null && item.runningCommands.Count > 0)
{
lock (item.runningCommands)
{
foreach (PowerShell key in item.runningCommands.Keys)
{
RunCommandsArguments runCommandsArgument1 = null;
PSActivity.ArgsTable.TryGetValue(key.InstanceId, out runCommandsArgument1);
if (runCommandsArgument1 == null)
{
continue;
}
PSActivity.RemoveHandlersFromStreams(key, runCommandsArgument1);
}
}
}
item.Cancel();
}
finally
{
context.MarkCanceled();
}
}