locked
Explanation for CancelationScope? RRS feed

  • Question

  • Hi,

    I feel I'm missing something very obvious, but I'm not getting how the "Using CancelationScope in an XAML File" workflow sample works.  There's a parallel activity that contains two CancellationScopeActivities.  Each CancellationScopeActivity contains a Sequence in the body, where a Delay activity defines when the Writeline activity is executed.  I see the DelayActivities are associated two different variables with different time durations.

    What I'm missing is, how does the body of the second (the one with the greater delay) CancellationScopeActivity not execute (the body)?  What signals the second CancellationScopeActivity not to execute its children?

    Thanks,
    Notre
    Wednesday, July 29, 2009 8:55 PM

Answers

  • Note that the completion condition of the parallel is 'true'.  You can see this in the properties panel when the parallel activity is selected (press F4 to get this).  As a result, when one branch completes, the other is canceled.  This wouldn't happen if the completion condition was false.

    Also, this rework of the sample may help explain cancellation scope: http://blogs.msdn.com/rjacobs/archive/2009/06/01/cancellationscope-activity.aspx.

    • Proposed as answer by Michael Wasser Friday, July 31, 2009 9:46 PM
    • Marked as answer by Notre Tuesday, August 4, 2009 5:58 PM
    Friday, July 31, 2009 9:44 PM

All replies

  • Note that the completion condition of the parallel is 'true'.  You can see this in the properties panel when the parallel activity is selected (press F4 to get this).  As a result, when one branch completes, the other is canceled.  This wouldn't happen if the completion condition was false.

    Also, this rework of the sample may help explain cancellation scope: http://blogs.msdn.com/rjacobs/archive/2009/06/01/cancellationscope-activity.aspx.

    • Proposed as answer by Michael Wasser Friday, July 31, 2009 9:46 PM
    • Marked as answer by Notre Tuesday, August 4, 2009 5:58 PM
    Friday, July 31, 2009 9:44 PM
  • Yes, the role of the completion condition on the parallel activity is what I was missing.  Thanks for clearing this up!  (The blog post was also useful).
    Tuesday, August 4, 2009 5:57 PM
  • But how does this cancelationScope works differently from the Sequence activity? as long as the completion condition is set to True, Sequence activity is also got canceled without putting it in a cancelationScope.
    Monday, November 23, 2009 4:10 PM
  • The CancelationScope Activity provides a CancelationHandler so you can create a cancelation model.
    Thanks,
    Scott
    MS Developer Support
    Monday, November 23, 2009 9:15 PM