private void ThreadProc() { try { while (!_stopFlag) { try { ConsoleCommand cmd = ConsoleCommandEvent.WaitAny(_recv); if (cmd == ConsoleCommand.INVALID) { Trace.WriteLine("failed to receive command"); } else { OnCommandReceived(cmd); } } catch (Exception e) { Trace.WriteLine(e); } } } catch (Exception e) { Trace.WriteLine(e); } }
public bool Start(int timeout) { if (_worker == null) { return(false); } if (!_workerInitialize.WaitOne(timeout)) { return(false); } _status = WorkerStatus.Ready; if (!WriteCommand(ConsoleCommand.StartCommand)) { return(false); } if (ConsoleCommandEvent.WaitAny(_startResponse, timeout) != ConsoleCommand.StartSuccess) { return(false); } _status = WorkerStatus.Running; return(true); }