Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement a asynchronized workflow?
    primarykey
    data
    text
    <pre><code> WorkflowInvoker invoker = new WorkflowInvoker(new Workflow1()); for (int i = 0; i &lt; 10; i++) { //invoker.InvokeAsync(myOrders); IAsyncResult result = invoker.BeginInvoke(myOrders,new AsyncCallback(WorkflowCompletedCallback),order); } </code></pre> <p>I use the above code to implement asynchronized workflow. I hope to run this workflow for 10 times and I have something similar with thread pool so the 10 workflow thread could run at the same time. The second doesn't need to wait for the first one finished its job. My workflow is very simple it will do some calculation and print several sentences on screen. After I run the above code, I find it seems the 10 workflows are invoked one by one not as what I hoped to run at the same time. What is the correct way to asynchronize workflow? Thank you!</p> <p>Update: After some feed back from others, I also try use workflowapplication to do this asynchronizely:</p> <pre><code> WorkflowApplication wfApp = new WorkflowApplication(new Workflow1(), myOrders); for (int i = 0; i &lt; 10; i++) { wfApp.Run(); } /* Read the end time. */ DateTime stopTime = DateTime.Now; Console.WriteLine(stopTime); // Duration TimeSpan duration = stopTime - startTime; Console.WriteLine("hours:" + duration.TotalHours); Console.WriteLine("minutes:" + duration.TotalMinutes); Console.WriteLine("seconds:" + duration.TotalSeconds); Console.WriteLine("milliseconds:" + duration.TotalMilliseconds); </code></pre> <p>Here is the running result: 4/8/2011 9:57:49 AM 4/8/2011 9:57:50 AM hours:6.27777777777778E-05 minutes:0.00376666666666667 seconds:0.226 milliseconds:226 Process Order Customer: 10 | Shipping:NextDay | Total Price:250 | Shipping Price:10 ProductID:1 | Quantity:5 | Price: 50 ProductID:2 | Quantity:10 | Price: 200</p> <p>It seems it is asynchronized but only one thread is actually running my workflow (not the main application thread). But from the output I only see one thread is running my workflow. How could I let 10 threads run the workflow at the same time? Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload