public static IObservable <T> Take <T>(this IObservable <T> source, int count)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            if (count == 0)
            {
                return(Empty <T>());
            }

            // optimize .Take(count).Take(count)
            TakeObservable <T> take = source as TakeObservable <T>;

            if (take != null && take.scheduler == null)
            {
                return(take.Combine(count));
            }

            return(new TakeObservable <T>(source, count));
        }
        public static IObservable <T> Take <T>(this IObservable <T> source, TimeSpan duration, IScheduler scheduler)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }

            // optimize .Take(duration).Take(duration)
            TakeObservable <T> take = source as TakeObservable <T>;

            if (take != null && take.scheduler == scheduler)
            {
                return(take.Combine(duration));
            }

            return(new TakeObservable <T>(source, duration, scheduler));
        }