Monday 15 August 2011

c# - Can Windows Workflow Runtime run 2 workflows at the same time -


We used the factory / singleton pattern to create workflow runtime.

When we run workflow we use an AutoResetEvent waitHandle.WaitOne () to wait to complete the workflow.

If two workflows run at the same time, then they respond to the same AutoResetEvent and receive the return value for both calls, the first call.

Is there any way to fix this without making a new workflow runtime for every call?

Thank you

Shiraz

Edit

Here is a simplified version of the code:

  Process of Public Sector: IPOs {Private AutoRate Event Wait Hangal = New AutoRetset (Incorrect); /// & lt; Summary & gt; /// Return values ​​will be & lt; /// & lt; / Summary & gt; Private dictionary & lt; String, Object & gt; ReturnValues; Public Process Carbo Preprocess (Processor Cargo Cargo) {Try {Workflow Runtime Workflow Time = Workflowfitter GatWorks flow runtime (); WorkflowtimeTime Workflow + = new event handler & lt; Workflow End Event Series & gt; (Complete workflow); WorkflowtimeTime Workflow Excluded + = New Event Handler & lt; Workflow determined event event & gt; (Workflow timed); Workflow Runtime Services ExceptionNotHolded + = New Event Handler & lt; ServicesExceptionNotHandledEventArgs & gt; (Workflowmantimize exception exception nothandedhand); Dictionary & lt; String, Object & gt; Parameter = New Dictionary & lt; String, Object & gt; (); // Add Parameters Workflow Instance Workflow Instance; Workflowinstance = workflowtimetime.createflow (typef (process workflow), parameter); WorkflowInstance.Start (); WaitHandle.WaitOne (); Cargo A = (A) Return value [KA]; } Hold (exception e) {LoggingHelper.LogFault (E); throw; } Return cargo; }  

This workflow factory is based on the step in the Windows Workflow Foundation step book:

  public static class workflowfree {// Workflow Runtime Private Static Workflowtimetime_workflowRuntime = single instance of tap; // lock (sync) object private static object _syncRoot = new object (); /// & lt; Summary & gt; /// factory method /// & lt; / Summary & gt; /// & lt; Returns & gt; & Lt; / Returns & gt; Public Static Workflow Runtime GetWorkflowRuntime () {// In case of multi-threaded // (concurrent) access lock execution thread Lock (_syncRoot) {// Check for Startup Status if provided (for zero == _workflowRuntime) {// Shutdown App Dotman. CurrentDomain.ProcessExit + = new event heredollar (stopwalkerflontemime); AppDomain.CurrentDomain.DomainUnload + = New EventHandler (StopWorkflowRuntime); // is not started, so create example _ workflow storage = new workflow runtime (); // runtime _workflowRuntime.StartRuntime start (); } // Return // Return Singleton Example Return _ WorkflowRertime; } // lock} // Shutdown method static zero StopWorkflowRuntime (Object Sender, EventArgs E) {If (_workflowRuntime! = Null) {if (_workflowRuntime.IsStarted) {try run // runtime _workflowRuntime.StopRuntime ()}; } {ObjectDisposedException} {// has already been dealt with, so ignore ...} // hold} // if} // if}}  

< Div class = "post-text" itemprop = "text">

A single Windows workflow runtime can run multiple workflows at the same time. The code you have placed around the runtime, which needs fixing.

What is waiting on the waiting handle? Why are you waiting? Why are you using the same handle for multiple workflow instances?


No comments:

Post a Comment