Click here to Skip to main content
15,896,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts

In my application there is a method named 'saveOutput'.
This Method will not execute very fast.
Also this method is in a loop (Will execute many times)
So I thought thread pool will be a good solution.

But I have never used thread pool.

all suggestion will be regard.

Thank you.
Posted

As a beginner, I would avoid ThreadPool in favor of BackgroundWorker[^]. The link has a good example of how to use it at the bottom of the page.
 
Share this answer
 
Comments
Meysam Toluie 18-Dec-13 23:54pm    
I am kind of beginner but I think starting lots of threads will not helping me even with BackgroundWorker. In Addition I had experience with BackgroundWorker.
In addition to Ron's comments, the end solution really depends on what you want/need to do with the output data - I'd think very carefully about the end-to-end problem first, without necessarily jumping into 'this must be threaded' etc

For example - what if you were inserting the output data into (and I'll pick the example deliberatly) a sqlite database ? You could have many threads trying to insert - which likely isnt going to work given the nature of sqlite - so, you might need a work/output 'shared' queue in the middle and a single processor that extracts an item of output from the queue and saves it to sqlite

Do you get what Im saying ?

obviously, if you're going to dump the output to a file, your problems are 'easier', but, what about a file-name - what if your filenameing convention doesnt give you a unique file, even if you get a temp file name from the system, based on a guid, what are you going to do ?

'g'
 
Share this answer
 
Comments
Meysam Toluie 18-Dec-13 23:49pm    
The method SaveOutput is not a method which only saves the data; It also prepares data.
Meanwhile I am writing an text file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900