T
trint
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(IAsyncResult ar)
{
int BytesRead;
string strMessage;
try
{
// Finish asynchronous read into readBuffer and return number of
bytes read.
BytesRead = client.GetStream().EndRead(ar);
if (BytesRead < 1)
{
// if no bytes were read server has close. Disable input window.
MarkAsDisconnected();
return;
}
// Convert the byte array the message was saved into, minus two for
the
// Chr(13) and Chr(10)
strMessage = Encoding.ASCII.GetString(readBuffer, 0, BytesRead -
2);
ProcessCommands(strMessage);
///
///
// Start a new asynchronous read into readBuffer.
client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new
AsyncCallback(DoRead), null);
ThreadFunction1 thr1 = new ThreadFunction1();
Thread tid1 = new Thread(new ThreadStart(thr1.getOneAtATime ) );
}
catch( Exception e)
{
MarkAsDisconnected();
}
}
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.performclick()"
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(IAsyncResult ar)
{
int BytesRead;
string strMessage;
try
{
// Finish asynchronous read into readBuffer and return number of
bytes read.
BytesRead = client.GetStream().EndRead(ar);
if (BytesRead < 1)
{
// if no bytes were read server has close. Disable input window.
MarkAsDisconnected();
return;
}
// Convert the byte array the message was saved into, minus two for
the
// Chr(13) and Chr(10)
strMessage = Encoding.ASCII.GetString(readBuffer, 0, BytesRead -
2);
ProcessCommands(strMessage);
///
///
// Start a new asynchronous read into readBuffer.
client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new
AsyncCallback(DoRead), null);
ThreadFunction1 thr1 = new ThreadFunction1();
Thread tid1 = new Thread(new ThreadStart(thr1.getOneAtATime ) );
}
catch( Exception e)
{
MarkAsDisconnected();
}
}
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.performclick()"
Help is appreciated.
Thanks,
Trint