/// <summary> /// constructor, /// </summary> /// <param name="HandleCarCoords">object to process received coordinates</param> public MqttRaceClient(IPerformTask <JCarCoords> HandleCarCoords) { InQ = new ProducerConsumerQueue <JCarCoords>(HandleCarCoords); // need to call worker thread from this thread OutQ = new ProducerConsumerQueue <MqttMessageEventArgs>(new MessagePublisher(this), true); }
/// <summary> /// Create a thread for reading items from the queue /// </summary> /// <param name="perform">object that can process queued tasks</param> /// <param name="runWorkerThread">false to stop the creation of a worker thread, the Work() function /// must be called to process tasks from the queue</param> public ProducerConsumerQueue(IPerformTask <T> perform, bool runWorkerThread = true) { if (runWorkerThread) { worker = new Thread(Work); worker.Start(); } Perform = perform; }