I have an app that uses the standard Socket Client code. I send it a
message to call a function and it receives the message, debugs through
the function, but the function doesn't actually fire. Anyone have a
clue? Here is the code:
public void DoRead(IAsyncRe sult ar)
{
int BytesRead;
string strMessage;
try
{
// Finish asynchronous read into readBuffer and return number of
bytes read.
BytesRead = client.GetStrea m().EndRead(ar) ;
if (BytesRead < 1)
{
// if no bytes were read server has close. Disable input window.
MarkAsDisconnec ted();
return;
}
// Convert the byte array the message was saved into, minus two for
the
// Chr(13) and Chr(10)
strMessage = Encoding.ASCII. GetString(readB uffer, 0, BytesRead -
2);
ProcessCommands (strMessage);
///
///
// Start a new asynchronous read into readBuffer.
client.GetStrea m().BeginRead(r eadBuffer, 0, READ_BUFFER_SIZ E, new
AsyncCallback(D oRead), null);
ThreadFunction1 thr1 = new ThreadFunction1 ();
Thread tid1 = new Thread(new ThreadStart(thr 1.getOneAtATime ) );
}
catch( Exception e)
{
MarkAsDisconnec ted();
}
}
the function that I need to run is getOneAtATime. The function works
with a button click...but will not work outside this thread, inside
this thread or even if i call the button click "button.perform click()"
Help is appreciated.
Thanks,
Trint
message to call a function and it receives the message, debugs through
the function, but the function doesn't actually fire. Anyone have a
clue? Here is the code:
public void DoRead(IAsyncRe sult ar)
{
int BytesRead;
string strMessage;
try
{
// Finish asynchronous read into readBuffer and return number of
bytes read.
BytesRead = client.GetStrea m().EndRead(ar) ;
if (BytesRead < 1)
{
// if no bytes were read server has close. Disable input window.
MarkAsDisconnec ted();
return;
}
// Convert the byte array the message was saved into, minus two for
the
// Chr(13) and Chr(10)
strMessage = Encoding.ASCII. GetString(readB uffer, 0, BytesRead -
2);
ProcessCommands (strMessage);
///
///
// Start a new asynchronous read into readBuffer.
client.GetStrea m().BeginRead(r eadBuffer, 0, READ_BUFFER_SIZ E, new
AsyncCallback(D oRead), null);
ThreadFunction1 thr1 = new ThreadFunction1 ();
Thread tid1 = new Thread(new ThreadStart(thr 1.getOneAtATime ) );
}
catch( Exception e)
{
MarkAsDisconnec ted();
}
}
the function that I need to run is getOneAtATime. The function works
with a button click...but will not work outside this thread, inside
this thread or even if i call the button click "button.perform click()"
Help is appreciated.
Thanks,
Trint
Comment