hi, need help.
i have made my client server application asynchronous, thats work well,
when i have modified the code i got an error. the error say
"InvalidOperationException". here is a half of my code:
//=====================================================
public void OnDataReceived(IAsyncResult asyn)
{
SocketPacket socketData = (SocketPacket)asyn.AsyncState ;
try
{
// Complete the BeginReceive() asynchronous call by EndReceive() method
// which will return the number of characters written to the stream
// by the client
int iRx = socketData.m_currentSocket.EndReceive (asyn);
char[] chars = new char[iRx + 1];
// Extract the characters as a buffer
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(socketData.dataBuffer,
0, iRx, chars, 0);

System.String szData = new System.String(chars);
//==============================================================
/// uncomment the code bellow toget INVALID_OPERATION_EXCEPTION:
//if(szData=="<execute>")
//{ProcesS.Start("cmd.exe");}
//==============================================================
string msg = "" + socketData.m_clientNumber + ":";
AppendToRichEditControl(msg + szData);

// Send back the reply to the client
string replyMsg = "Server Reply:" + szData.ToUpper();
// Convert the reply to byte array
byte[] byData = System.Text.Encoding.ASCII.GetBytes(replyMsg);

Socket workerSocket = (Socket)socketData.m_currentSocket;
workerSocket.Send(byData);

// Continue the waiting for data on the Socket
WaitForData(socketData.m_currentSocket, socketData.m_clientNumber );

}
catch (ObjectDisposedException )
{
System.Diagnostics.Debugger.Log(0,"1","\nOnDataReceived: Socket has been closed\n");
}
catch(SocketException se)
{
if(se.ErrorCode == 10054) // Error code for Connection reset by peer
{
string msg = "Client " + socketData.m_clientNumber + " Disconnected" + "\n";
AppendToRichEditControl(msg);

// Remove the reference to the worker socket of the closed client
// so that this object will get garbage collected
m_workerSocketList[socketData.m_clientNumber - 1] = null;
UpdateClientListControl();
}
else
{
MessageBox.Show (se.Message );
}
}
}

//===================================================================
my question is haw i can make safety thread while asynchronous progress run.
(IF POSIBLE TO PAUSE THE ASYNC OPERATION!!!!)
dont ask me to use BackgroundWorker component to run the Process.Start();
please another way. thanks verymuch...........

HERE IS MY CODE CLIENT-SERVER
http://all-uneed.net/wp-content/uplo...ynchronous.rar

COMPILE USING "csc <thesourcecode>.cs" at cmd