i have designed a class for posting data to server, which is a time consuming task so that i have used background worker in my application. instead of repeatedly using backgroundworker in my application, i decided to add it to my class and generate two events PostWorkerReportProgress, PostWorkerComplted for my application. how can i do that?. any example please.
views:
113answers:
1
A:
first, to use the PostWorkerReportProgress, you must tell the background worker object that it can use the ReportProgress functionality.
Now, to get to the PostWorkerCompleted event, just finish the DoWorks method. Exiting that method automatically generates the WorkerCompleted event. If you're allowing the CANCELLATION of the background worker, then make sure that you explicity set the e.Cancel=true in the DoWorks method before exiting it.
For the reports Progress, you must explicitly call the function of the backgroundworker object which does this.
backgroundwrkrObject.ReportProgress(int)
backgroundwrkrObject.ReportProgress(int, object)
Stephen Wrighton
2009-09-14 13:36:33