Here is the simple code for invoking the WF with Input and Output parameters using C#
Dictionary<string, object> parameters = new Dictionary<string, object>();
Employer emp = new Employer();
emp.FirstName = txtFirstName.Text;
emp.LastName = txtLastName.Text;
emp.DOB = txtDOB.SelectedDate;
emp.Email = txtEmail.Text;
parameters["Emp"] = emp;
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted += delegate(object sender1,
WorkflowCompletedEventArgs e1)
{
lblResult.Text = e1.OutputParameters["Result"].ToString();
waitHandle.Set();
};
workflowRuntime.WorkflowTerminated += delegate(object sender2,
WorkflowTerminatedEventArgs e2)
{
lblResult.Text = e2.Exception.Message;
waitHandle.Set();
};
WorkflowInstance instance =
workflowRuntime.CreateWorkflow(typeof(EmployerWorkFlow), parameters);
instance.Start();
waitHandle.WaitOne();
}
Employer emp = new Employer();
emp.FirstName = txtFirstName.Text;
emp.LastName = txtLastName.Text;
emp.DOB = txtDOB.SelectedDate;
emp.Email = txtEmail.Text;
parameters["Emp"] = emp;
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted += delegate(object sender1,
WorkflowCompletedEventArgs e1)
{
lblResult.Text = e1.OutputParameters["Result"].ToString();
waitHandle.Set();
};
workflowRuntime.WorkflowTerminated += delegate(object sender2,
WorkflowTerminatedEventArgs e2)
{
lblResult.Text = e2.Exception.Message;
waitHandle.Set();
};
WorkflowInstance instance =
workflowRuntime.CreateWorkflow(typeof(EmployerWorkFlow), parameters);
instance.Start();
waitHandle.WaitOne();
}
No comments:
Post a Comment