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

  • SEARCH
  • Home
  • 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 6775921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:57:52+00:00 2026-05-26T15:57:52+00:00

I have a desktop app (.net 3.5) which communicates with the server using classic

  • 0

I have a desktop app (.net 3.5) which communicates with the server using classic web services.
I need to make numerous calls to web service functions, wait for them all to finish, and then proceed.

I’d like to do these calls in parallel; so obviously I’m looking to utilize the MyFunctionAsync method.
The thing is- i’m not sure how to verify that all calls have returned. I’m probably missing some simple synchronization mechanism here.

here’s what i’d like to be able to do:

public void DoWork()
{
   service.MyFuncCompleted+= MyFunc_Completed;
   foreach (var i in items)
   {
      service.MyFuncAsync(i);
      syncMechanism.WaitForAnother(1);  //signal that we have to wait for 1 more task to finish
   }
   syncMechanism.WaitForAllTasksToFinsih();  //wait until specified number of tasks have finished

   //continue
}

public void MyFunc_Completed(EventArgs e)
{
   //process result...
   syncMechanism.Signal(1);  //signal that 1 task has finished
}

anybody know anything like this is c#?

  • 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-26T15:57:53+00:00Added an answer on May 26, 2026 at 3:57 pm

    This ( fork / join ) is a lot easier in .NET 4, but you’re on 3.5 so you’ll have to do it the old-fashioned way.

    Basically, increment a counter for each operation and then decrement it in your Completed handler. Then check if it’s got down to zero and if so signal a wait handle to indicate all operations have completed.

    Here’s an example of the idea:

    static ManualResetEvent mre = new ManualResetEvent( false );
    static int inFlight = 1; // start with 1 to fix race condition
    
    static void DoWork()
    {
        for ( int i = 0 ; i < 10 ; i++ )
        {
            var bw = new BackgroundWorker();
    
            bw.DoWork += bw_DoWork;
            bw.RunWorkerCompleted += bw_RunWorkerCompleted;
    
            Interlocked.Increment( ref inFlight );
    
            bw.RunWorkerAsync();
        }
    
        if ( Interlocked.Decrement( ref inFlight ) == 0 ) mre.Set();
    
        mre.WaitOne(); // this blocks until all workers have completed
    }
    
    static void bw_DoWork( object sender, DoWorkEventArgs e )
    {
        Thread.Sleep( 1000 );
    }
    
    static void bw_RunWorkerCompleted( object sender, RunWorkerCompletedEventArgs e )
    {
        if ( Interlocked.Decrement( ref inFlight ) == 0 ) mre.Set();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an .NET 4 .exe (Winform Desktop app) to which I have added
We are using ASP.Net Web services. The architecture is Desktop Based Application developed in
Using .NET, I have a requirement in which I need to execute a process
So, I have this desktop app built using WPF and C#. It's basically an
I have a desktop application which contains an App.config (program.exe.config at release) with clearly
I have a scenario where I need a desktop console app to communicate with
i have written a java program which currently runs as a desktop app, it
I have a .net winforms app which has a few animation effects, fade ins
I have created a .Net application to run on an App Server that gets
We have a .NET 2.0 winforms app that connects to a SQL Server 2005

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.