Hi, How can i check from my NativeActivity if the 'Cancel' method of the workflow application was invoked?
I tried to use the 'IsCancellationRequested' property of the context but it doesn`t much.
Here is my sample:
public class Program
{
static void Main(string[] args)
{
ManualResetEventSlim mre = new ManualResetEventSlim(false);
WorkflowApplication app = new WorkflowApplication(new Sequence() { Activities = {new tempActivity(), new tempActivity() } });
app.Completed += delegate(WorkflowApplicationCompletedEventArgs e)
{
mre.Set();
};
app.Run(TimeSpan.MaxValue);
Thread.Sleep(2000);
app.BeginCancel(null,null);
mre.Wait();
}
}
public class tempActivity : NativeActivity
{
protected override void Execute(NativeActivityContext context)
{
Console.WriteLine("Exec tempActivity");
for (int i = 0; i < 10; i++)
{
Thread.Sleep(1000);
Console.Write(".");
if (context.IsCancellationRequested)
return;
}
}
}
Thanks!