public static Envelope[] ReceiveItems(
            this TelemetryHttpListenerObservable listener,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            var result = listener
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .ToEnumerable()
                         .ToArray();

            return(result);
        }
        public static Envelope[] ReceiveItems(
            this TelemetryHttpListenerObservable listener,
            int count,
            int timeOut)
        {
            if (null == listener)
            {
                throw new ArgumentNullException("listener");
            }

            var result = listener
                         .TakeUntil(DateTimeOffset.UtcNow.AddMilliseconds(timeOut))
                         .Take(count)
                         .ToEnumerable()
                         .ToArray();

            if (result.Length != count)
            {
                throw new InvalidDataException("Incorrect number of items. Expected: " + count + " Received: " + result.Length);
            }

            return(result);
        }