troubleshooting Question

C#: Use Multi-threading to send email or other activity (request for code-snippet)

Avatar of MohitPandit
MohitPanditFlag for India asked on
.NET ProgrammingC#
5 Comments1 Solution29 ViewsLast Modified:
Hello Folks,

I've a table with 50 hundred records which I need to send as email or sms (daily) through C#.
Instead to use one-by-one to send email, I've two options

1. Async Programming with TPL (Task Parallel Library) using await & async
2. Multi-threading programming in C#

I believe that I should use multi-threading in C# as TPL doesn't do tasks at same time. Right?

Apart, in multi-threading C#, do you have code snippet for below use case in C#?
1. Use Thread-Pool
2. Use configurable threads & chunk size like 2 threads with 5 chunk size, means one thread will handle 5 records at same time
3. Addition, in case any records completed (email sent) by thread out of 5 records. Example, 1 record' email sent then queue next record with same thread. So that thread should not wait to complete all 5 records to finish.

Do you have other thoughts too?

Best Regards,
Mohit Pandit

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros