I’m an indolent developer like other 🙂 and why I try to write a static method to use BackgroundWorker any where. this method is the blew:
public static void RunInThread( DoWorkEventHandler method
,ProgressChangedEventHandler progressHandler
,RunWorkerCompletedEventHandler completed)
{
var bkw = new BackgroundWorker();
bkw.DoWork += method;
bkw.ProgressChanged += progressHandler;
bkw.RunWorkerCompleted += completed;
bkw.WorkerReportsProgress = true;
bkw.RunWorkerAsync();
}
but i have a problem for use the BackgroundWorker.ReportProgress method.
Is there anyone here who can help me?
tnx
What if instead of returning
voidfromRunInThreadyou return an object ofBackgroundWorkerclass(bkw) and then in yourDoWorkuse that instace to callbackgroundWorker.ReportProgress();