I Hope I used the right term
What I'm aiming for is something like this (I realise it doesn't work that way):
private bool someBool = false;
BackgroundWorker bg = new BackgroundWorker();
bg.DoWork += new DoWorkEventHandler(DoLengthyTask);
bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
()=>
{
someBool = true;
Logger.Info("Finished");
}
)
The important part being the RunWorkerCompletedEventHandler being defined within the scope of the original caller and by that having access to the caller's variables.
Is this possible? Would it generate possible race conditions on the someBool?