Checking for Form.IsDisposed
on the UI thread before updating the UI is the way to go, and will avoid any race conditions.
If you handle the FormClosing
event as suggested by John Willemse, you will be able to request cancellation of the task - but there can still be a race condition which means the task will complete and update the UI.