示例#1
0
        public override bool Add(Action d, bool forceDelayed = true)
        {
            if (!sleeper.IsSleeping || isMainThread)
            {
                base.Add(d, forceDelayed);
                return(true);
            }
            ThreadPool.QueueUserWorkItem(State =>
            {
                if (sleeper.IsSleeping)
                {
                    sleeper.Invoke(d);
                }
                else
                {
                    Add(d, forceDelayed);
                }
            });

            return(false);
        }
示例#2
0
        public override bool Add(Action task, bool forceScheduled = true)
        {
            if (!sleeper.IsSleeping || IsMainThread)
            {
                base.Add(task, forceScheduled);
                return(true);
            }
            ThreadPool.QueueUserWorkItem(state =>
            {
                if (sleeper.IsSleeping)
                {
                    sleeper.Invoke(task);
                }
                else
                {
                    Add(task, forceScheduled);
                }
            });

            return(false);
        }