Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

background worker thread issue in windows form application

Tags:

c#-4.0

Im exporting a reports from dataset to a execel file,i have a lots of reports so it consuming me a lots of time,so I try to solve this by the background worker cuz I'm working on windows form application,but the new issue come,when begin excuting the report my form is not responding,I'm not able to move the form or click on the stop button(that stop the application).

this is a sample of my code :

#region x Report 

PrimaryReportsThreads++;
ADIR_Parameters ADIR_Parms = ConfigManager.GetADIRParameters();
BackgroundWorker ADIR_worker = new BackgroundWorker();
AllThreads.Add(ADIR_worker);
ADIR_worker.DoWork += new DoWorkEventHandler(ADIR_worker_DoWork);
ADIR_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
ADIR_worker.RunWorkerAsync(ADIR_Parms);

#endregion
like image 470
jozef Avatar asked Apr 23 '26 02:04

jozef


1 Answers

Sounds like COM issue. Probably you should try using MTA, instead of STA

Helpfull links:

http://msdn.microsoft.com/en-us/library/ms809971.aspx

http://msdn.microsoft.com/en-us/library/system.threading.apartmentstate.aspx

like image 181
Philipp Munin Avatar answered Apr 24 '26 14:04

Philipp Munin