开发者

MultiThreading in C# and how to handle

I have a requirement in which i need to call开发者_StackOverflow中文版 webservice 12 times for one request. What i am planning creating that number of threads and call the service from ThreadStartMethod ... Now the questions are

  1. I need to kill all other threads if i got proper result from any of the response
  2. I heard killing thread by using Thread.abort is dangerous .

Please advice

Thanks


Don't use threads at all. See my answer to this question here:

Using ThreadPool threads with long running ADO.NET queries. Is this scalable?

Use asp.net's built-in async processing instead.


Thread.abort will throw an ThreadAbortException and is usually not a very good idea, since aborting a thread will always leave your application in an undefined state.
It's considered to be better practice to do some sort of polling to stop the thread in a more 'graceful' way when a flag is set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜