I have been looking over several examples of backgroundworkers and I ran across code that looks similar to this
public class MyClass
{
public MyClass()
{
using(BackgroundWorker _Worker = new BackgroundWorker { WorkerReportsProgress = true})
{
_Worker.DoWork += (s, args) =>
{
...
};
}
_Worker.RunWorkerAsync();
}
}
I have not been using the "using" statment in my code like this. I ran across something similar while using the Code Rush trial, which made me come back to this code and question if i should be doing this or not. Please help me understand if/why this would be best practice. Thanks.