private void ServerThread(ServerHandler handler) { ItemReceiver r = new ItemReceiver(handler.stream); game.RegisterCurrentThread(); while (true) { object o; do { o = r.Receive(); if (o == null) return; } while (HandleInterrupt(o)); handler.semAccess.WaitOne(); handler.queueIn.Enqueue(o); handler.semAccess.Release(1); handler.semIn.Release(1); } }
private void ServerThread(Stream stream, Semaphore semWake, Semaphore semAccess, Queue<object> queueIn) { ItemReceiver r = new ItemReceiver(stream); game.RegisterCurrentThread(); while (true) { object o; do { o = r.Receive(); if (o is int) { Trace.TraceInformation("{0} Received a {1}", Thread.CurrentThread.Name, (int)o); } { Trace.TraceInformation("{0} Received a {1}", Thread.CurrentThread.Name, o.GetType().Name); } } while (HandleInterrupt(o)); semAccess.WaitOne(); queueIn.Enqueue(o); semAccess.Release(1); semWake.Release(1); } }