Now I found a simpler way of doing multi-threading programming in C#: using the Backgroundworker component.
For it to work properly, you must make sure that "any" interaction with UI (controls on your Windows form) must be done at the "ProgressChanged" event handler of your BackgroundWorker component.
The following is a summary of the things you need to do for using the backgroundworker component:
(1) Add the backgroundworker component to your form
(2) Set the "WorkerReportsProgress" property of the backgroundworker to True
(3) Set the "WorkerSupportsCancellation" property of the backgroundworker to True
(4) Create the event handler of the backgroundworker for "DoWork", "ProgressChanged" and "RunWorkerCompleted"
(5) Put in the statements or procedures to be executed by the backgroundworker inside the event handler of "DoWork". This should be the starting point of the thread-processing. This event will be fired when you execute the statement such as
backgroundWorker1.RunWorkerAsync();
The sample codes can be found here
Reference in MSDN
This blog captures some of the thoughts, ideas and things that am learning, researching and exploring on areas such as: Project Management, Software Development, Open Source, etc. Feel free to feedback or comment :)
Subscribe to:
Post Comments (Atom)
Converting a Physical Linux to Virtual
Hmm ... I have done a lot of work on my Linux Lubuntu 15.10 with PHP and PostgreSQL and a few other things ... it is quite time-consuming to...
-
I have got the book: Crucial Confrontation ! It is really a great book. After reading it, I learned a very valuable lesson on how to deal wi...
-
A requirement study stage should not be left "open-ended". There should be key review milestones specified for checking the accura...
-
Here are something to read about PM KPI: KPI explained When we want to create KPIs for PM, we need to use the CSC (Critical Success Criter...
1 comment:
For Multhithreading - Synchronization Primitives
Visit : http://csharp-multithreading.blogspot.com/
Post a Comment