Original Post
Hi! I have the following code that needs to be rewritten. I need to use another way of waithing the next thread to finish not using wile loops....I want something like WaitForSingleObject ....is there a way to do it in C# without dllImport...?? THX a lot
Thread ExecThread = new Thread(new ThreadStart(SendDataToRemoteServer));
ExecThread.Start();
int TimeToWait=0;
int IncomingTimeOut=120000;
while ((ExecThread.IsAlive)&&(TimeToWait<IncomingTimeOut))
{
Thread.Sleep(100);
TimeToWait=TimeToWait+100;
}
if(ExecThread.IsAlive)
{
ExecThread.Abort();
ExecThread.Join();
string LogMsg="";
LogMsg="Thread Aborted ";
if(Subject!=null)
{
LogMsg=LogMsg+"Subject :";
LogMsg=LogMsg+Subject;
}
LogClass.WriteToLog(InfoLevel1,LogMsg);
}