private IDisposable ScheduleSlow <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action)
        {
            var userWorkItem = new UserWorkItem <TState>(this, state, action);

            var res = ThreadPoolTimer.CreateTimer(
                tpt => userWorkItem.Run(),
                dueTime);

            userWorkItem.CancelQueueDisposable = res.AsDisposable();

            return(userWorkItem);
        }
        /// <summary>
        /// Schedules an action to be executed.
        /// </summary>
        /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
        /// <param name="state">State passed to the action to be executed.</param>
        /// <param name="action">Action to be executed.</param>
        /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
        /// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
        public override IDisposable Schedule <TState>(TState state, Func <IScheduler, TState, IDisposable> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var userWorkItem = new UserWorkItem <TState>(this, state, action);

            var res = ThreadPool.RunAsync(
                iaa => userWorkItem.Run(),
                Priority,
                Options);

            userWorkItem.CancelQueueDisposable = res.AsDisposable();

            return(userWorkItem);
        }