fCraft.Scheduler.NewTask C# (CSharp) Method

NewTask() public static method

Creates a new SchedulerTask object to run in the main thread. Use this if your task is time-sensitive or frequent, and your callback won't take too long to execute.
public static NewTask ( [ callback ) : SchedulerTask
callback [ Method to call when the task is triggered.
return SchedulerTask
        public static SchedulerTask NewTask( [NotNull] SchedulerCallback callback )
        {
            return new SchedulerTask( callback, false );
        }

Same methods

Scheduler::NewTask ( [ callback, [ userState ) : SchedulerTask

Usage Example

Example #1
0
        static void openDoor(Zone zone, Player player)
        {
            int sx = zone.Bounds.XMin;
            int ex = zone.Bounds.XMax;
            int sy = zone.Bounds.YMin;
            int ey = zone.Bounds.YMax;
            int sz = zone.Bounds.ZMin;
            int ez = zone.Bounds.ZMax;

            Block[] buffer = new Block[zone.Bounds.Volume];

            int counter = 0;

            for (int x = sx; x <= ex; x++)
            {
                for (int y = sy; y <= ey; y++)
                {
                    for (int z = sz; z <= ez; z++)
                    {
                        buffer[counter] = player.WorldMap.GetBlock(x, y, z);
                        player.WorldMap.QueueUpdate(new BlockUpdate(null, new Vector3I(x, y, z), Block.Air));
                        counter++;
                    }
                }
            }

            DoorInfo info = new DoorInfo(zone, buffer, player.WorldMap);

            //reclose door
            Scheduler.NewTask(doorTimer_Elapsed).RunOnce(info, DoorCloseTimer);
        }
All Usage Examples Of fCraft.Scheduler::NewTask