fCraft.Scheduler.AddTask C# (CSharp) Method

AddTask() static private method

Schedules a given task for execution.
static private AddTask ( [ task ) : void
task [ Task to schedule.
return void
        internal static void AddTask( [NotNull] SchedulerTask task )
        {
            if ( task == null )
                throw new ArgumentNullException( "task" );
            lock ( TaskListLock ) {
                if ( Server.IsShuttingDown )
                    return;
                task.IsStopped = false;
            #if DEBUG_SCHEDULER
                FireEvent( TaskAdded, task );
                if( Tasks.Add( task ) ) {
                    UpdateCache();
                    Logger.Log( LogType.Debug,
                                "Scheduler.AddTask: Added {0}", task );
                }else{
                    Logger.Log( LogType.Debug,
                                "Scheduler.AddTask: Added duplicate {0}", task );
                }
            #else
                if ( Tasks.Add( task ) ) {
                    UpdateCache();
                }
            #endif
            }
        }

Usage Example

Example #1
0
 SchedulerTask RunForever()
 {
     IsRecurring = true;
     NextTime    = DateTime.UtcNow.Add(Delay);
     Scheduler.AddTask(this);
     return(this);
 }
All Usage Examples Of fCraft.Scheduler::AddTask