Exemplo n.º 1
0
 public ScheduledDelegate AddDelayed <T>([NotNull] Action <T> task, T data, double timeUntilRun, bool repeat = false)
 {
     // We are locking here already to make sure we have no concurrent access to currentTime
     lock (queueLock)
     {
         ScheduledDelegate del = new ScheduledDelegateWithData <T>(task, data, currentTime + timeUntilRun, repeat ? timeUntilRun : -1);
         Add(del);
         return(del);
     }
 }
Exemplo n.º 2
0
        public ScheduledDelegate Add <T>([NotNull] Action <T> task, T data, bool forceScheduled = true)
        {
            if (!forceScheduled && IsMainThread)
            {
                //We are on the main thread already - don't need to schedule.
                task.Invoke(data);
                return(null);
            }

            var del = new ScheduledDelegateWithData <T>(task, data);

            enqueue(del);

            return(del);
        }