Closing all dialogs on logout

  • Thread starter Thread starter Joshua T. Moore
  • Start date Start date
J

Joshua T. Moore

Here is the layout to understand the problem:
Application.Run calls LogonDlg.cs
LogonDlg (if login successful) opens Form1.cs
Form1.cs opens Form2.cs

I have an app where a network packet received on a socket logs out the user
back to the login screen. This works great if the form1 is the active one,
but if I open form2 (showDialog()) and the packet comes in, the form1 sets
form2 to null, and gets an "Argument Excpeption" when the form1 tries to set
it's DialogResult and return to LogonDlg.

Please help.

Thanks,
Joshua Moore
 
Yes,

I tried the following code per dialog that was not null:

if (form2 != null)
{
form2.DialogResult = DialogResult.Cancel;
form2.Dispose();
form2 = null;
}

the "Argument Exception" comes when I try to set the form1 dialogresult to
ok.

Thanks for the suggestion,
Josh
 
Back
Top