Red Swan
Red Swan

Reputation: 15545

How to use multithreading in c# for sending

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.

Upvotes: 1

Views: 677

Answers (2)

niao
niao

Reputation: 5070

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

Upvotes: 0

TomTom
TomTom

Reputation: 62101

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.

Upvotes: 1

Related Questions