views:

47

answers:

3

How to use multithreading in c# for 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.

+1  A: 

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.

TomTom
A: 

Thread Pooling

TheMachineCharmer
A: 

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

niao