Re: C# Multithreading
From: jimirwin (USERjimirwin_at_DOMAINholoscenes.org)
Date: 06/01/04
- Next message: DotNetJunkies User: "Re: overloaded methods and exported tlb method names?"
- Previous message: Phil Wilson: "Re: Binary compatability?"
- In reply to: Michael C: "Re: C# Multithreading"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 01 Jun 2004 23:28:32 GMT
Michael C wrote in microsoft.public.dotnet.framework.interop:
>... For some servers it takes up to 10 seconds to get a
>response, and locking up the UI/not returning a response for 700 secs is
>not an option. I'm trying to use an array of WaitHandle objects to wait
>until all the methods are complete, but I think I may be stuck with the
>700 sec delay again. Is there a way to call the function that requests
>server info 70 times, each on separate threads and gather/use the
>results as each thread completes? Can anyone point me in the right
>direction?
The approach I might take would be to set up a worker thread to make the
calls, and keep the user out of trouble with an application modal progress
dialog that cannot be closed until all the servers have responded or timed
out (or the user cancels the operation). Presumbably the user has
requested this poll directly or indirectly though some action, so they
might expect and accept some wait?
You can still use async delegates as your worker threads -- let each
callback function send a message to the progress dialog; when the dialog
detects that all the callback messages have been received, it closes.
Depending on how many delegates you let loose at one time, and how many
threads the runtime has available in the pool, you should be able to cut
down the wait substantially.
If a progress dialog is unacceptable and the user has to be allowed to do
other things in your application while the poll is in progress, then I
would definitely set up a separate worker thread, and have that thread send
a message to your main thread when it completes the polling. Once you
start a poll, you would want to disable any menu items or widgets that
might allow the user to trigger another concurrent poll.
-- Jim Irwin http://www.holoscenes.com
- Next message: DotNetJunkies User: "Re: overloaded methods and exported tlb method names?"
- Previous message: Phil Wilson: "Re: Binary compatability?"
- In reply to: Michael C: "Re: C# Multithreading"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|