I have the following code in my worker thread (ImageListView
below is derived from Control
):
if (mImageListView != null &&
mImageListView.IsHandleCreated &&
!mImageListView.IsDisposed)
{
if (mImageListView.InvokeRequired)
mImageListView.Invoke(
new RefreshDelegateInternal(mImageListView.RefreshInternal));
else
mImageListView.RefreshInternal();
}
However, I get an ObjectDisposedException
sometimes with the Invoke
method above. It appears that the control can be disposed between the time I check IsDisposed
and I call Invoke
. How can I avoid that?