none
ScheduleActivity Method Returns Immediately?

    Question

  • 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

    Monday, February 27, 2012 7:35 PM

Answers