void HandleIncommingStream()
 {
     if (queue.Count > 0)
     {
         queue.Dequeue().SetResult(Listener.AcceptStream());;
     }
     else
     {
         WaitingConnections++;
     }
 }
        public Task <TStream> AcceptStreamAsync()
        {
            var tcs = new TaskCompletionSource <TStream>();

            if (WaitingConnections > 0)
            {
                WaitingConnections--;
                tcs.SetResult(Listener.AcceptStream());
            }
            else
            {
                queue.Enqueue(tcs);
            }
            return(tcs.Task);
        }