Hello all,

I'm new to WF and trying to image how to develop a time-boxed activity. Basically it should look like a sequence activity, allowing the user to drop activities into it, but it should also have a Timeout property, after which if the activities in the sequence are not complete, it ends and sets some public WasTimeout property to true.

The basic problem I'm having is envisioning this conceptually. I mean, WF executes activities synchronously, so activities in the BAL don't seem to help (Parallel certainly doesn't, Listen would kinda work, but has the problems that I'm not listening for events, plus I'd like my activity to look like a sequence, without branches).

An idea I have is to just derive host a SequenceActivity in my activity, but after calling sequence.Execute start a Timer, on whose Tick I'd check if the timeout interval elapsed. Would this work at all What about in the context of dehydration (I'm thinking it should work, but I'm a newbie as I said Smile ).

Any ideas to point me in the right direction


Re: Windows Workflow Foundation Timeboxed activity

Angel Azcarraga - MSFT

What you're looking for is essentially a hybrid between a SequenceActivity and a DelayActivity. You want to implement your activity so that before all, it creates a durable timer subscription for the amount specific in the Timeout property you expose. Here's an example:

TimerEventSubscription timerSub = new TimerEventSubscription((Guid)queueName, this.WorkflowInstanceId, timeOut);

WorkflowQueue queue = qService.CreateWorkflowQueue(queueName, false);

queue.RegisterForQueueItemAvailable += timeoutEventHandler;

This will create a timer that when it fires, will call your event handler. In your event handler, you'll want to cancel an executing activities and close your activity.


Re: Windows Workflow Foundation Timeboxed activity

Rashad Rivera


Can you provide a bit more contect for novice developers of WF I get your jest, but don't know where I can get (or what the type is of) the "qService" object you mentioned. I mean is it part of the WorkflowRuntime class How would I practically gain an instance of it from within my Activity Thanks in advance.

- Rashad Rivera