static Client() { clientQueueThread = new Thread(() => { AutoResetEvent waitEvent = new AutoResetEvent(false); while (true) { DateTime? next; lock (clientQueueLock) { if (clientQueue.Count == 0) next = null; else next = clientQueue.Peek().lastRequest; } if (next == null) { clientQueueResetEvent.WaitOne(); continue; } TimeSpan waitTime = next.Value.Add(TimeSpan.FromSeconds(31)).Subtract(DateTime.Now); if (waitTime > TimeSpan.Zero) waitEvent.WaitOne(waitTime); Client client; lock (clientQueueLock) client = clientQueue.Dequeue(); if (DateTime.Now.Subtract(client.lastRequest) > TimeSpan.FromSeconds(30)) SpotifireServer.Instance.MessageClients(c => c.Ping(), client); } }); clientQueueThread.IsBackground = true; clientQueueThread.Start(); }
private Client(ISpotifireClient client) { this.client = client; }