My WinForm makes a call that takes some duplicate action, I want to show progress on one form about it.
I want to use the background writer, but I do not know how to report the progress of the form (/ background worker) from the class
Use the method to report progress and subscribe to backgroundworker to update your progress GUI.
Your copy class knows backgroundworker and subscribe to changing progress . It also exposes itself to the progress of the event, which has been raised by the event handler for the event progress of the background worker
Code:
Public class CopySomethingAsync {Private backgroundworker _BackgroundWorker; Public Event Progressiveenthehandler progression; Public CopySomethingAsync () {//} ... Create background workers, subscribe to DoWork and RunWorkerCompleted _BackgroundWorker. Changed progress + = handles change progress; } Private Wide Handle Progress Changed (Object Sender, Progress Changed Event ARG E) {If (Progress changed! = Null) progress has been changed. Invoke (this, e); }} Just subscribe to progress change event CopySomethingAsync and show progress.
Comments
Post a Comment