ScheduleActivity Method Returns Immediately?
-
Monday, February 27, 2012 7:35 PM
Hello All,
I've got a ScheduleActivity call within one of my CodeActivities which is returning immediately. The Activity it's scheduling is a Delay, with a Duration of 30 seconds, yet it returns immediately.
Here's some code:
protected override void CacheMetadata(NativeActivityMetadata metadata) { mDelay.Duration = TimeSpan.FromSeconds(30); metadata.AddImplementationChild(mDelay); base.CacheMetadata(metadata); } private bool DoRetryable(Func<bool> function, TimeSpan timeout, NativeActivityContext context) { bool result = false; DateTime start = DateTime.Now; while ((DateTime.Now - start) < timeout) { result = function(); if (result) { break; } context.ScheduleActivity(mDelay); } return result; } private readonly Delay mDelay = new Delay();The ScheduleActivity(mDelay) call is returning right away. I figured it would execute the Activity, which has its Duration set to 30 seconds.
Any ideas?
My educational lectures on C# and .Net in general (ranging from beginner level topics to advanced topics): mariocatch.wordpress.com
All Replies
-
Wednesday, February 29, 2012 10:12 AM
Hi,
The workflow engine schedule activities in unspecified execution order, this should be the reason you got unexpected behavior.
Basic Activity Scheduling in Workflow 4.0
http://blogs.msdn.com/b/tilovell/archive/2010/01/27/basic-activity-scheduling-in-workflow-4.0.aspx
- Marked As Answer by LeoTangModerator Monday, March 05, 2012 11:03 AM

