BTool.CommManager.DataRxPollThread C# (CSharp) Method

DataRxPollThread() private method

private DataRxPollThread ( object threadData ) : void
threadData object
return void
        private void DataRxPollThread(object threadData)
        {
            try
            {
                threadCtrl.Init();
                threadCtrl.RunningThread = true;
                SharedObjects.Log.Write(Logging.MsgType.Debug, "CommManager", "Starting Thread");
                while (!threadCtrl.ExitThread)
                {
                    if (threadCtrl.PauseThread)
                    {
                        threadCtrl.IdleThread = true;
                        SharedObjects.Log.Write(Logging.MsgType.Debug, "CommManager", "Pausing Thread");
                        threadCtrl.EventPause.WaitOne();
                        threadCtrl.IdleThread = false;
                        if (threadCtrl.ExitThread)
                            break;
                    }
                    int bytesToRead = ComPort.BytesToRead;
                    if (bytesToRead > 0)
                    {
                        byte[] bytes = new byte[bytesToRead];
                        ComPort.Read(bytes, 0, bytesToRead);
                        if (fp_rxDataInd != null)
                            fp_rxDataInd(bytes, bytes.Length);
                    }
                    else
                        Thread.Sleep(10);
                }
            }
            catch (Exception ex)
            {
                msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, "Task Thread Problem.\n" + ex.Message + "\nCommManager\n");
            }
            SharedObjects.Log.Write(Logging.MsgType.Debug, "CommManager", "Exiting Thread");
            threadCtrl.Exit();
        }