This post says that when you call the BeginInvoke
method on a delegate, it is always necessary to call the EndInvoke
method. Another post backs it up and suggests the class BackgroundWorker
as an alternative.
I used ILSpy to decompile BackgroundWorker
and I have found out that actually, EndInvoke
is never called in this class, even though it does use BeginInvoke
on a delegate.
Does this mean that BackgroundWorkder
is ill-implemented, or is calling EndInvoke
not so necessary after all?
(The issue with exceptions being lost is irrelevant, since the whole method being invoked is enclosed in a try-catch block)
On a similar matter: it there a clear reason why BeginInvoke
was chosen in implementation of BackgroundWorker
over say, ThreadPool.QueueUserWorkItem()
?
Edit: the source code of BackgroundWorker
can be viewed here.