It's possible to define some start values to an workflow using WorkflowInstance.CreateWorkflow
, like this:
using(WorkflowRuntime runtime = new WorkflowRuntime())
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("First", "something");
parameters.Add("Second", 42);
WorkflowInstance instance =
runtime.CreateWorkflow(typeof(MyStateMachineWorkflow), parameters);
instance.Start();
waitHandle.WaitOne();
}
This way, a MyStateMachineWorkflow
instance is created and First
and Second
public properties gets that dictionary values.
But I'm using WCF; so far, I managed to create a Start
method which accepts that two arguments and I set that required fields by using bind on my ReceiveActivity
:
using (WorkflowServiceHost host =
new WorkflowServiceHost(typeof(MyStateMachineWorkflow)))
{
host.Open();
ChannelFactory<IMyStateMachineWorkflow> factory =
new ChannelFactory<IMyStateMachineWorkflow>("MyStateMachineWorkflow");
IMyStateMachineWorkflow proxy = factory.CreateChannel();
// set this values through binding on my ReceiveActivity
proxy.Start("something", 42);
}
While this works, that create an anomaly: that method should be called only and exactly once.
How can I start an workflow instance through WCF passing those arguments? On my tests, I just actually interact with my workflow through wire after I call that proxy method. Is there other way?