how to control the many asynchronous thread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was told .net uses ThreadPool to manage the threads generated by the
asynchronous methods automaticly, I had written a program with C# such as
In MainMethod
……
…….BeginInvoke(new AsyncCallback(Method1CallBack), null);
……
In Method1CallBack:
……
…….BeginInvoke(new AsynCallback(Method2CallBack),null);
……
In Method2CallBack:
……
DoSomething;
……
a series of asynchronous methods were invoked one by one, I made several
threads invoke the MainMethod, thus there were many asynchronous threads,but
the whole process is automatic controled by the system, how can i control the
whole process, such as teminate some of these asynchronous threads or restart
them,should i set several switches to prevent the continuing executions in
the beginning of each asychronous method?
 
You can't control the mechanism - you don't own the threads so musn't terminate them. etc. Other pieces of the framework use the threadpool as well as you. The only way you can do this is to use a custom thread pool such as Mike Woodring's

http://www.bearcanyon.com/dotnet/#threadpool

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<[email protected]>

I was told .net uses ThreadPool to manage the threads generated by the
asynchronous methods automaticly, I had written a program with C# such as
In MainMethod
&hellip;&hellip;
&hellip;&hellip;.BeginInvoke(new AsyncCallback(Method1CallBack), null);
&hellip;&hellip;
In Method1CallBack:
&hellip;&hellip;
&hellip;&hellip;.BeginInvoke(new AsynCallback(Method2CallBack),null);
&hellip;&hellip;
In Method2CallBack:
&hellip;&hellip;
DoSomething;
&hellip;&hellip;
a series of asynchronous methods were invoked one by one, I made several
threads invoke the MainMethod, thus there were many asynchronous threads,but
the whole process is automatic controled by the system, how can i control the
whole process, such as teminate some of these asynchronous threads or restart
them,should i set several switches to prevent the continuing executions in
the beginning of each asychronous method?

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004



[microsoft.public.dotnet.framework]
 
Back
Top