Using parameters in BackgroundWorker handlers Using parameters in BackgroundWorker handlers multithreading multithreading

Using parameters in BackgroundWorker handlers


You can assign the value of e.Result in worker1_DoWork

static void worker1_DoWork(object sender, DoWorkEventArgs e){    //Do the work    //...    e.Result = new MyParams();}

Then you can get it in the worker1_RunWorkerCompleted in e.Result.

If you need to pass additional result value and you don't want to put MyParams object in the worker1_DoWork: e.Result - then you can create a small class ResultHolder with MyParams and MyResult as properties and use that class to pass the result in worker1_DoWork