This is my first time dealing with big multi threading project so please bear with me. We are writing a window service which will loop on the database table and generate SSRS reports based on records found. I am trying to write this as a multi thread system.
// THIS IS LONG RUNNING TASK
void ProcessReport(Report report)
{
ReportExecutionService rs = new ReportExecutionService();
rs.Credentials = new NetworkCredential(id,pass);
rs.Url = "url...asmx";
rs.ExecutionHeaderValue = new ExecutionHeader();
rs.Timeout = Timeout.Infinite;
string historyID = null;
ExecutionInfo info = rs.LoadReport("/../ReportName", historyID);
}
Inside ProcessReport() Method, I make call to ReportExecutionService and generate the SSRS report. This is long running task, can take up to 12 hours. Here is option 1 to open new thread for each REPORT I want to generate. We shall limit the number of thread we open
foreach(Report report in reportList)
{
if (report.ReportID != null)
{
Thread thread = new Thread(() => ProcessReport(report));
thread.Start();
}
}
Questions:
- Is this efficient way to call Reporting Web Service ?
- I am overwhelmed with all the different options of multi threading like TASK, BackgroundWorker, Thread, ThreadPool. Is there a better way to achieve my goal than what I have above ?