public bool Connect(int port) { InitConnector(); string[] ports = SerialUtilities.getPortNames(); if (port >= ports.Length) { return(false); } Disconnect(); _serialPort.PortName = ports [port]; _serialPort.BaudRate = 115200; try { _serialPort.Open(); }catch (Exception e) { Debug.Log("Failed to open serialPort:" + e.Message); } if (_serialPort.IsOpen) { Debug.Log("Connected to Robot at port: " + ports[port]); _thread.Start(); } return(_serialPort.IsOpen); }
private void AddThreadsToWorkingList() { if (bsWaiting.Count() > 0)// if the waiting list has any threads { ThreadWork threadWork = bsWaiting.First(x => x.Number == bsWaiting.Max(y => y.Number)); bsWaiting.Remove(threadWork); bsWorking.Add(threadWork); //the semaphore is sent as a parameter to the ThreadWork class. threadWork.Start(_s); } }
internal void StartPublishThread() { if (!IsCopy) { return; } var threadWork = new ThreadWork(); threadWork.Start("OnSubscribeIEnumerable<T>", () => { var ts = DateTime.Now - CacheDataTime; if (ts.TotalSeconds > 1) { rePublish(); } return(true); }, 0.5); }