Sorry. Let me explain it. I am developing a C# Winform application. It is not a MDI application, it is a SDI, somw wizard like stuff. The first screen contains a Media Player control, and playing a Movie from net. So the first form loading taking some time. And I need to add a Login for this application. So I wrote the code like this.
Login
void SignIn_Click(Object o, EventArgs e)
{
//Code for Authentication
if(IsAuthenticated())
{
MainForm MainUI = new MainForm();
MainUI.Show();
this.Close();
}
}
And the Program static class, I wrote like
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Login());
}
But when ever I am calling this.Close() the whole application is ending. I found some work around like Hiding the Login form and in the Main Window closing, I am closing the owner window too.
Like this
void SignIn_Click(Object o, EventArgs e)
{
//Code for Authentication
if(IsAuthenticated())
{
MainForm MainUI = new MainForm();
MainUI.Show(this);
this.Hide();
}
}
And in MainForm_FormClosing event
if(this.OwnerForm != null)
{
this.OwnerForm.Dispose()
}
It is working fine. But I think it is not the right way of doing it. Is there any other option available?
Thanks
Anuraj P
http://www.dotnetthoughts.net
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.