I'm using WF to run activities and I would like to invoke the activity synchronously on the same thread as the calling thread. How would I do that using WorkflowInvoker.Invoke? The following is my code snippet:
public int RunTransactionActivity(ActivityInputBundle inputBundle)
{
int returnCode = 100;
ActivityFactory actFactory = new ActivityFactory();
NativeActivity NA = null;
NA = actFactory.GetTransactionActivity(inputBundle.ActivityName);
Dictionary<string, object> inputs = new Dictionary<string, object>();
inputs.Add("InputBundle", inputBundle);
IDictionary<string, object> output;
output = WorkflowInvoker.Invoke(NA, inputs);
returnCode = Int32.Parse(output["ReturnCode"].ToString());
return returnCode;
}
The problem is, it seems, the activity (NA) is running on a different thread. Is there a way for me have the activity run on the same thread? I've read articles where the SynchronizationContext can be used to do that with the WorkflowApplcation, but I'm having issues using WorkflowApplication.Run() with output/return parameters.