public void Add(MTConnectConnection connection) { if (connection != null) { queue.GetOrAdd(connection.DeviceId, connection); } }
private void Worker() { do { var connections = queue.Select(o => o.Value).ToList(); if (connections != null && connections.Count > 0) { var connection = connections[0]; // Start the MTConnectConnection connection.Start(); // Raise event to notify that the connection has started ConnectionStarted?.Invoke(connection); // Remove from queue MTConnectConnection dummy = null; queue.TryRemove(connection.DeviceId, out dummy); } } while (!stop.WaitOne(Delay, true)); }