protected override void OnTick() { // check the server requests list and process anything found on it // find the queue entry for the message and return the result DefragRequests(); foreach (QueuedMessage q in ServerRequests) { if (!q.Completed) { // otherwise just run it in the current thread try { // process the message q.MessageOut = q.MessageIn.ProcessMessage(); } catch (Exception e) { q.MessageOut = new ErrorMessage(String.Format("Error processing outgoing message. {0}", e.Message)); } q.Completed = true; // just do one per tick to minimize server blocking break; } } if (!Enabled) { // clear any pending requests and stop the service ServerRequests.Clear(); Stop(); } }