Closing all dialogs on logout

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
 
J

Joshua T. 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top