private void TaskThread(object threadData)
{
try
{
bool flag = false;
ThreadCtrl.Init();
ThreadCtrl.RunningThread = true;
SharedObjects.Log.Write(Logging.MsgType.Debug, "RxDataInThread", "Starting Thread");
while (!flag)
{
if (ThreadCtrl.ExitThread)
break;
if (ThreadCtrl.PauseThread)
{
ThreadCtrl.IdleThread = true;
SharedObjects.Log.Write(Logging.MsgType.Debug, "RxDataInThread", "Pausing Thread");
ThreadCtrl.EventPause.WaitOne();
ThreadCtrl.IdleThread = false;
if (ThreadCtrl.ExitThread)
break;
}
switch (WaitHandle.WaitAny(new WaitHandle[3]
{
(WaitHandle) ThreadCtrl.EventExit,
(WaitHandle) ThreadCtrl.EventPause,
(WaitHandle) DataQueue.qDataReadyEvent
}))
{
case 0:
flag = true;
if (!ThreadCtrl.ExitThread)
continue;
else
continue;
case 1:
ThreadCtrl.EventPause.Reset();
SharedObjects.Log.Write(Logging.MsgType.Debug, "RxDataInThread", "Resuming Thread");
continue;
case 2:
DataQueue.qDataReadyEvent.Reset();
QueueDataReady();
continue;
default:
flag = true;
continue;
}
}
}
catch (Exception ex)
{
string msg = "Task Thread Problem.\n" + ex.Message + "\nRxDataInThread\n";
msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, msg);
}
SharedObjects.Log.Write(Logging.MsgType.Debug, "RxDataInThread", "Exiting Thread");
ThreadCtrl.Exit();
}