I have a boolean function. I have a bw which I wish to use to run this function. I want to get the return value from the function, is it possible?
Here is a sample code:
void Main ()
{
BackgroundWorker backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += (sender1, e1) => testBool();
bool result = backgroundWorker.RunWorkerAsync;
}
bool testBool()
{
return true;
}
Is it possible?
Thanks.
You can subscribe to BackgroundWorker.RunWorkerCompleted event to recieve a notification about a fact that the computaion terminated.
Inside that testBool(..)
you can set global variable, and after inside
the event handler of RunWorkerCompleted
read that value.