开发者

How to use multithreading in c# for sending

How to use multithreading in c# f开发者_如何学Goor sending the SMS to multiple person at a times? Use must of multithread. means must execute sms sending code/process independently at a time. (synchronisely) how can i do this ? please guide.


Start reading the documentation - or a book like "c# in 21 days".

  • System.Threading is your namespace for threads. Opening a thread is trivial, but I would not go that way.
  • Look into ThreadPool and queue a WorkItem for every SMS. The ThreadPool will automatically start threads. This is more memory efficient than using static threads, especially if you use that in multiple places of your application (as threads may get shared).

There are ample of samples for using WorkItems.

http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem%28VS.71%29.aspx

is a decent start documentation wise.


Well, In my project in WCF service I use for instance ThreadPool class for sending emails. In that case emails will be quequed and this will ensure that service will not "hang". Creating lots of different threads may lead to clogging of the system

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜