I have a .Net application with multiple forms invoked using form.ShowDialog()
. When I do Application.Exit
, the application is not closing all the forms.
When I try to do an explicit Form.Close
I am getting an error from WinForms as below
at Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar) at System.Windows.Forms.Form._CloseModal() at System.Windows.Forms.Form.Close() at
As @CharithJ states in this answer (paraphrased):
Cancel the background worker and send an argument to the
BackgroundWorker
RunWorkerCompleted
event to identify that time has expired. From that event you can callApplication.Exit()
just fine.