private static void HandleClientThread() { while (!Handler.Shutdown.Token.IsCancellationRequested) { Context context; while (ContextQueue.Count == 0) { Thread.Sleep(10); if (Handler.Shutdown.IsCancellationRequested) { return; } } if (!ContextQueue.TryDequeue(out context)) { continue; } lock (ContextMapping) { WebSocketServer server = ContextMapping[context]; server.SetupContext(context); } lock (CurrentConnections){ CurrentConnections.Add(context); } } }
private static void HandleClientThread() { try { while (!cancellation.Token.IsCancellationRequested) { Context context; while (ContextQueue.Count == 0) { Thread.Sleep(10); if (cancellation.Token.IsCancellationRequested) { return; } } if (!ContextQueue.TryDequeue(out context)) { continue; } context.Server.SetupContext(context); lock (CurrentConnections){ CurrentConnections.Add(context); } } } catch (Exception ex) { Console.WriteLine(ex); } }
private static void HandleClientThread() { while (true) { Context context; while (ContextQueue.Count == 0) { Thread.Sleep(10); } if (!ContextQueue.TryDequeue(out context)) { continue; } lock (ContextMapping) { WebSocketServer client = ContextMapping[context]; client.SetupContext(context); } lock (CurrentConnections){ CurrentConnections.Add(context); } } }