help: messagebox-like delay?

R

Risa

hi, i created a windows application that uses winsock control.
in the closing event, it sends a "Disconnect" string message.
the server (listening application) does not receive this message.

also in the closing event, a Messagebox is shown when not all values
have been saved.
when this is shown, the "Disconnect" message is received by the
listening application.

in most times, the messagebox is not shown.
my question is, how can the message be sent?
i tried thread.sleep and lock but it does not work.

btw, i am using .net 1.1 / Visual studio 2003
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Would you mind posting some code?

Are you doing a Flush before closing teh connection?

Is the connection in another trehad?
 
R

Risa

i use winsock control
i don't close the connection. the server just waits for a message.

private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
try
{
if (m_bIsConnectedToEDAS)
{
SendMessage("Disconnect");
}

if (bDataNeedsUpdate)
{
DialogResult dr = MessageBox.Show("Do you want to save before
continuing?","
Application",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);

if (dr == DialogResult.Yes)
{
Save();
}

if (dr == DialogResult.No)
{
return;
}
catch
{ // some code

}
finally
{// some code}
}



private void SendWinsockMessage(string sMessage)
{
try
{
winSock1.SendData(sMessage);
}
catch (Exception ex)
{ // some code
}
}
 

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