MohitPandit
asked on
C#: Window Service with thread pool
Hello Folks,
FYI, actually, I need to send emails from multiple databases (schema is same) then, I would like to use thread pool.
I would like to create a window service in C# which will be having below features:
1. I would like to use Thread Pool in window service;
2. The threads will be configurable like 2 threads.
3. The chunk size will be configurable like 5 i.e. records chunk size.
4. Could you please provide me code snippet for this?
Like,
a.) Aforesaid 1 to 3 points
b.) I need to put logic to utilize threads once idle. For example, two threads (using Thread Pool) are running in window service;
c.) And 500 emails need to send;
d.) Pre-assume, we have set 2 threads and 5 records chunk size; That means, 10 records records are processing in two threads
e.) So, window service logic should not wait to complete 10 records. In case one of the thread is free then assign next 5 records chunk size.
Best Regards,
Mohit Pandit
FYI, actually, I need to send emails from multiple databases (schema is same) then, I would like to use thread pool.
I would like to create a window service in C# which will be having below features:
1. I would like to use Thread Pool in window service;
2. The threads will be configurable like 2 threads.
3. The chunk size will be configurable like 5 i.e. records chunk size.
4. Could you please provide me code snippet for this?
Like,
a.) Aforesaid 1 to 3 points
b.) I need to put logic to utilize threads once idle. For example, two threads (using Thread Pool) are running in window service;
c.) And 500 emails need to send;
d.) Pre-assume, we have set 2 threads and 5 records chunk size; That means, 10 records records are processing in two threads
e.) So, window service logic should not wait to complete 10 records. In case one of the thread is free then assign next 5 records chunk size.
Best Regards,
Mohit Pandit
then you need to enable a FIFO queue
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi Sara,
Sure, I'll take a look over it and update you.
Best Regards
Sure, I'll take a look over it and update you.
Best Regards
ASKER
Thanks