Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C# question is there a way to way to create a background worker thread without having a form in a project. I have created a .dll project and I was instructed to call a class/function using the background worker thread. I'm not sure how to do this. Any help would be great. I"m sure there is an easy answer I'm just not familiar with this tool.

Thanks
Posted

Yes, of course.

BackgroundWorker does not need any User interface. So you can just create the object of it from Code, available at System.ComponentModel.


BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerAsync();



The worker_DoWork will be called in a new thread after you call RunWorkerAsync.

:)
 
Share this answer
 
Thanks so much for the quick response :-D
 
Share this answer
 

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