Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi, I am very new to multi threading. my requirment is read the data from DB(universe DB) and create the report and export to excel. there might muliple report created say 10 to 15 reports
Here what i have to do is two threads 1) read the data from DB for reports 2)with each data create excel
And these process should work as background process.
Pls help, any idea to do this is deeply appreciated.

Thanks in Advance.
Posted

1 solution

That doesn't make a whole load of sense: why have two threads doing this? Why not have a thread (from the BackgroundWorker[^] pool) for each report? Then it keeps the related tasks together - each thread reads data, create report, export to excel, end thread.
Otherwise, you have to pass data between the threads, presumably using some form of queue - it's much easier to handle if the thread handles the whole task, particularly as the next stage can't start until the previous one is complete.
 
Share this answer
 
Comments
Member 8056507 4-Jul-11 6:53am    
@OriginalGriff - Thanks for ur response. Why i thought of 2 thread is, querying the data from DB also time consuming and with generating the report. So while the thread is generating a report(as excel) let the other thread queries the data from DB. Both the thread should be Synchronized. Any other idea is also welcomed.
OriginalGriff 4-Jul-11 6:56am    
Why go to that complexity? If you use them as background threads and an operation is slow, then others can "get in" and do something - they won't all lock up waiting for the DB read to finish.
Member 8056507 4-Jul-11 7:00am    
thanks OriginalGriff - Can u pls provide me a optimal solution for this ?

i not sure how to work with threads. If u have any code samples pls help with it.
OriginalGriff 4-Jul-11 7:06am    
If you follow the original link, MSDN provides sample code which will help!
Member 8056507 4-Jul-11 7:17am    
thanks. i will have a look.

Thanks again.

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