how to implement multithreading in c#

  • Thread starter Thread starter Shoukat Hayt,
  • Start date Start date
S

Shoukat Hayt,

Hi!
i am a professional developer and i have made an antivirus. but when i start
scanning if we click on the dialog or minimize or any other work on that
dialog.
it goes on busy state, and after complition of scaning it will displayed in
actual state.
this occures because i am scnaing and the drawing of form both done in same
thread. i try my best to run in different format but failed. is there any
body who help me. i will be very great full of him.
i think if the code of stop watch like software will help me most.
send me the link where i find that code. or any other help acording to
threading will
be appriciated.

thanx.

shoukat hayat

(e-mail address removed)
(e-mail address removed)
 
i am a professional developer and i have made an antivirus. but when i start
scanning if we click on the dialog or minimize or any other work on that
dialog.
it goes on busy state, and after complition of scaning it will displayed in
actual state.
this occures because i am scnaing and the drawing of form both done in same
thread. i try my best to run in different format but failed. is there any
body who help me. i will be very great full of him.
i think if the code of stop watch like software will help me most.
send me the link where i find that code. or any other help acording to
threading will
be appriciated.

Do the long running task in its own thread and update the form
via Invoke.

Arne
 
Hi!
i am a professional developer and i have made an antivirus. but when i start
scanning if we click on the dialog or minimize or any other work on that
dialog.
it goes on busy state, and after complition of scaning it will displayed in
actual state.
this occures because i am scnaing and the drawing of form both done in same
thread. i try my best to run in different format but failed. is there any
body who help me. i will be very great full of him.
i think if the code of stop watch like software will help me most.
send me the link where i find that code. or any other help acording to
threading will
be appriciated.

thanx.

shoukat hayat

(e-mail address removed)
(e-mail address removed)

The BackgroundWorker class can make threading very simple. Take a look
at the documentation here:
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx.
 
Shoukat said:
[...]
this occures because i am scnaing and the drawing of form both done in same
thread. i try my best to run in different format but failed. is there any
body who help me. i will be very great full of him.
i think if the code of stop watch like software will help me most.
send me the link where i find that code. or any other help acording to
threading will
be appriciated.

As Arne and Mike have said, there are a variety of ways to approach
this, the two main ones being to use a dedicated thread and explicitly
use Control.Invoke() to deal with the UI, and using the BackgroundWorker
which implicitly uses the thread pool as well as implicitly does the
same work Control.Invoke() does when raising the ProgressChanged and
RunWorkerCompleted events.

Beyond that, there have been dozens of threads on these very topics in
this newsgroup. So one good place to start is to just use Google Groups
to search the newsgroup for those discussions.

Pete
 
Back
Top