Hope I used the correct term
What I'm aiming for is something like this (I understand this doesn't work):
private bool someBool = false; BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += new DoWorkEventHandler(DoLengthyTask); bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler( ()=> { someBool = true; Logger.Info("Finished"); } )
An important part is the RunWorkerCompletedEventHandler, defined within the scope of the original call and to those who have access to the variables of the caller.
Is it possible? Will this generate possible race conditions on someBool?
multithreading c # lambda
Boris Callens
source share