Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4329984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:53:56+00:00 2026-05-21T09:53:56+00:00

WorkflowInvoker invoker = new WorkflowInvoker(new Workflow1()); for (int i = 0; i < 10;

  • 0
        WorkflowInvoker invoker = new WorkflowInvoker(new Workflow1());

        for (int i = 0; i < 10; i++)
        {
            //invoker.InvokeAsync(myOrders);
            IAsyncResult result = invoker.BeginInvoke(myOrders,new AsyncCallback(WorkflowCompletedCallback),order);
        }

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!

Update: After some feed back from others, I also try use workflowapplication to do this asynchronizely:

        WorkflowApplication wfApp = new WorkflowApplication(new Workflow1(), myOrders);
        for (int i = 0; i < 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);

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

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:53:57+00:00Added an answer on May 21, 2026 at 9:53 am

    If you’re checking the IAsyncResult inside your loop, that will block until the async method has completed. The IAsyncResult is provided so that you can use an asynchronous method synchronously, which is not what you’re trying to do here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Windows Workflow and trying to write a Long Running process.
am new to Windows Workflow [WF], and interested in evaluating WF for business purposes.
I`m gettin the following exception while invoking my workflow (dynamically): The following errors were
This is proof of concept project - The goal is to create an application
I'm looking hard at WF 4.0 right now, but I'm having a hard time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.