|
index > Windows Workflow Foundation > Setting custom HandleExternalEventActivity properties on activati... |
|
Setting custom HandleExternalEventActivity properties on activati... |
|
|
I have what must be a common and simple requirement in my WF application but I am unable to see how it it can easily be achieved.
The application contains a large library of custom activities, many of which subclass from a single "UserActivity" activity, which in turn derives from HandleExternalEventActivity. These are all human activities, which block until a user sends a message to the runtime (hosted in WS) from the client application to notify the WF that the current activity is completed. All of this works fine.
However, during creation (not invocation) of each UserActivity for the first time I want to set some properties from internal business rules. For example, UserActivity has a DateTime property called TargetFinishTime. This is set to by adding a configured period to DateTime.Now at the time of activity creation . I am not binding property values and I do not want to set this value from the containing WF or from the previous activity (the activities are resued across many WFs). All I want is a method/event where I can set up some internal state of the HandleExternalEventActivity after it is "activated" and before it is unloaded to the persistence DB after the WF idles waiting on the external event. The Execute event is obviously unsuitable here, as is Initialize (both are sealed in HEE). Contructor doesn't work as this is used by the designer.
Am I barking up the wrong tree here or is there an easy way of doing this? Should I be writing my own IEventActivity implementation? | | Spigot | Can you explain what you mean by "Contructor doesn't work as this is used by the designer."?
Khalid Aggag - MSFT | | Khalid Aggag - MSFT | Sorry, that was misleading. VS.NET gave me a compile error because I tried to access the WorkflowInstanceId property in a log statement in the ctor (System.InvalidOperationException: This is an invalid design time operation. You can only perform the operation at runtime.)
However, using the ctor of the custom Activity does not work, even after removing the log statement: the problem is that each Activity constructor is called when the workflow instance is started (it is actually called twice for each Activity, once for the definition and once for the actual activity instance, as far as I understand it). The ctor is not called when the Activity is activated, as it is deserialized from persistence store at this stage. Setting time-dependant values like TargetFinishTime makes no sense here as the constructor call does not indicate the actual "activation" of the activity.
What I need is a lifecycle event that indicates that a HandleExternalEvent activity has become active and is now the waiting activity in the workflow.
| | Spigot |
|
|
| reply 3 |
|
|
|
You can use google to search for other answers |
|
|
|
|
More Articles |
|
| Whats the Scenario? |
| Is WF adequated to build an OLTP middleware tier? |
| Windows workflow in ASP.Net |
| Editing XOML in VS2005 and other designer problems |
| What do i have to do in order to use SqlWorkflowPersistenceServic... |
| where are changes to theme properties stored? |
| multiple inouts to an activity |
| Problem in installing WinFX |
| Custom HandleExternalEventActivity ParameterBindings problem |
| Why can't I inherit from InvokeWebServiceActivity? |
|