I am working on a client that is sending a request to the server to login and if it's accepted the main window shall be hidden and user will start work on the form 2 named user_form ... and there are 3 buttons available for the users on the user_form ( logout - exit - hide )
I want control them all from the main window which is already hidden ,,,
Here is the code I am working with in main form ... but it's not working as I want.
switch (client.LoginInfo.Limited)
{
case true:
this.Hide();
User_Form LF = new User_Form(client);
LF.AdminControlIsVisible = false;
DialogResult dr = LF.ShowDialog(this);
if (dr == System.Windows.Forms.DialogResult.Cancel)
{
//logout
}
else if (dr == System.Windows.Forms.DialogResult.OK)
{
if (client != null)
{
//hide
}
else
{
UpdateSystemMessage("No response from the server !!");
}
return;
}
break;
case false:
User_Form LF = new User_Form(client);
LF.AdminControlIsVisible = false;
DialogResult dr = LF.ShowDialog(this);
this.Visible = false;
if (dr == System.Windows.Forms.DialogResult.Cancel)
{
//logout
}
else if (dr == System.Windows.Forms.DialogResult.OK)
{
if (client != null)
{
//hide
}
else
{
UpdateSystemMessage("No response from the server !!");
}
return;
}
break;
}
Any solution ?
I fixed it by adding a new thread to run the .net sockets in instead of the main thread .