Reputation: 5990
I want to close a form showing as dialog by main thread. I am using beginInvoke to show that dialog and want to close or hide when worker thread complete its own task.
Upvotes: 0
Views: 884
Reputation: 18443
Same as showing the form, for closing the form you can also use BeginInvoke() or Invoke().
form.Invoke(new Action(form.Close));
or if the code is inside the form itself, replace the form with this.
Upvotes: 1
Reputation: 1805
If you are using the BackgroundWorker, there is a event available: "OnRunWorkerCompleted" - It triggers if the worker has completed.
You can use this event to close your form.
Upvotes: 2