private static void ThreadPoolWorker(object state) { Thread.CurrentThread.Name = "ReliableChannel Thread"; ThreadChecker.ConfigureReliable(Thread.CurrentThread); ReliableChannel[] channels = new ReliableChannel[100]; int channelCount = 0; do { lock (socketLock) { aliveSockets.CopyTo(channels); channelCount = aliveSockets.Count; } for (int index = 0; index < channelCount; index++) { var channel = channels[index]; try { channel.socket.Receive(); channel.writer.Use(channel.socket.Send); } catch (ObjectDisposedException) { ioRunning = false; } catch (Exception ex) { Logging.Logger.Log($"Exception thrown in ThreadPool\n{ex}"); } } } while (ioRunning); Logging.Logger.Log("ReliableChannel ThreadPool EXITING"); ThreadChecker.ConfigureReliable(null); }
public static void Remove(ReliableChannel channel) { ThreadChecker.AssertReliableChannel(); lock (socketLock) { aliveSockets.Remove(channel); } }