We help IT Professionals succeed at work.

c# what is the difference between a background worker thread and a asynccallback?

2,480 Views
Last Modified: 2013-12-17
c# what is the difference between a background worker thread and a asynccallback?
Comment
Watch Question

Commented:
a background worker thread works continously
a asynccallback thread is only created when an event call for it to be created.

Commented:
a background worker thread is a daemon thread...doesn't die until program is ended.

Author

Commented:
Thanks, but could you explain a little more, I really don't understand.

Maybe a better quesiton is why would you use each?
xakemSoftware Application Developer

Commented:
It may be assumed that asynccallback is a derivative of a background worker thread, but asynccallback is  used when you need two threads to complete some task without waiting of the initiator thread for the other thread to complete the task.
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi        jackjohnson44;

A Asynccallback is a delegate / pointerto a method that is passed to a separate running thread and is used tonotify the creator of the thread that the thread has completed  itsprocess.
From Microsoft documentation and show an example:
http://msdn.microsoft.com/en-us/library/system.asynccallback.aspxUsean AsyncCallback delegate to process the results of an asynchronousoperation in a separate thread. The AsyncCallback delegate represents acallback method that is called when the asynchronous operationcompletes. The callback method takes an IAsyncResult parameter, whichis subsequently used to obtain the results of the asynchronousoperation.

A BackgroundWorker is a component which simplifiesthe creation of a thread for a long running process and has events tosimplify the modification of GUI controls in the GUI thread. It alsohas an event RunWorkCompleted to inform the thread creator that thethread has completed.

So basically a Asynccallback is a delegatethat points to a method that can be used with threading to let you knowwhen the thread is finish and a BackgroundWorker is a component thatcreates a thread for a process and has events like a control.

Fernando
Fernando SotoRetired
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Hi jackjohnson44;

Reposting because last post has been modified by this new RichBox control on this web site.

A Asynccallback is a delegate /pointer to a method that is passed to a separate running thread and is used to notifythe creator of the thread that the thread has completed  its process.
From Microsoft documentation and show an example:
http://msdn.microsoft.com/en-us/library/system.asynccallback.aspxUsean
AsyncCallback delegate to processthe results of an asynchronous operation in a separate thread. TheAsyncCallback delegate represents a callback method that is called when theasynchronous operation completes. The callback method takes an IAsyncResultparameter, which is  subsequently used toobtain the results of the asynchronous operation.

A BackgroundWorker is a component which simplifies the creation of a thread fora long running process and has events to simplify the modification of GUIcontrols in the GUI thread. It also has an event RunWorkCompleted to inform thethread creator that the thread has completed.

So basically a Asynccallback is a delegate that points to a method that can beused with threading to let you know when the thread is finish and aBackgroundWorker is a component that creates a thread for a process and hasevents like a control.

Fernando



 

Author

Commented:
so if I only need to know when somethign is done and that is all, I can use asynch, if I want to do something more complex, like checking the status of somethign, use a thread.  Is this correct?
Retired
CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.