I use this function courtesy of a Stack Overflow user to update controls from a BackgroundWorker
.
static void SynchronizedInvoke(ISynchronizeInvoke sync, Action action)
{
// If the invoke is not required, then invoke here and get out.
if (!sync.InvokeRequired)
{
// Execute action.
action();
// Get out.
return;
}
// Marshal to the required thread.
sync.Invoke(action, new object[] { });
}
This function has worked perfectly until now. I just got this exception:
What does this mean and how do I prevent it?