/// <summary> /// Gets the next message from the server by repeatedly polling the message queue /// </summary> /// <returns>Message from server</returns> /// <throws>TaskCanceledException if task is cancelled</throws> private string CheckForStringMessage() { string s = null; var waitHandles = new WaitHandle[] { stringMessageQueue.eventWaiter, net.ctSource.Token.WaitHandle }; while (!stringMessageQueue.TryDequeue(out s)) { EventWaitHandle.WaitAny(waitHandles); net.ctSource.Token.ThrowIfCancellationRequested(); } return(s); }
/// <summary> /// Gets the next message from the server by repeatedly polling the message queue. /// </summary> /// <returns>Message from server</returns> /// <throws>TaskCanceledException if task is cancelled</throws> private ProtoMessage CheckForProtobufMessage() { ProtoMessage m = null; var waitHandles = new WaitHandle[] { protobufMessageQueue.eventWaiter, net.ctSource.Token.WaitHandle }; while (!protobufMessageQueue.TryDequeue(out m)) { EventWaitHandle.WaitAny(waitHandles); net.ctSource.Token.ThrowIfCancellationRequested(); } return(m); }