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.
Actually BackgroundWorker
does not need to be disposed, see here. So there is no need to have the using
clause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With