Here is an overview of my workflow implementation:
- The GUI thread starts the workflow.
- workflow parses some data
- a workflow launches several other workflows to work on subsets of data
- each of these last workflows creates a workflow workspace and runs a consistent workflow
So far, I have created a new WorkflowRuntime object in each thread, for example:
using( WorkflowRuntime workflow_runtime = new WorkflowRuntime()) {
AutoResetEvent waitHandle = new AutoResetEvent(false);
workflow_runtime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();};
workflow_runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = workflow_runtime.CreateWorkflow(typeof(MyWorkflow), parameters);
instance.Start();
waitHandle.WaitOne();
}
The reason for this is because I need to know when a particular workflow instance was interrupted or failed. The problem is that it causes a huge memory leak in my application, as mentioned here, on SO .
using, Dispose workflow_runtime null, . , Singleton, , . , .
, Singleton WF, , ? , , ?
EDIT: , , , , ? .