当前位置: 首页>>代码示例>>C#>>正文


C# SchedulerTask.RunRepeating方法代码示例

本文整理汇总了C#中fCraft.SchedulerTask.RunRepeating方法的典型用法代码示例。如果您正苦于以下问题:C# SchedulerTask.RunRepeating方法的具体用法?C# SchedulerTask.RunRepeating怎么用?C# SchedulerTask.RunRepeating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fCraft.SchedulerTask的用法示例。


在下文中一共展示了SchedulerTask.RunRepeating方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChatTimer

 ChatTimer( TimeSpan duration, [CanBeNull] string message, [NotNull] string startedBy )
 {
     if( startedBy == null ) throw new ArgumentNullException( "startedBy" );
     StartedBy = startedBy;
     Message = message;
     StartTime = DateTime.UtcNow;
     EndTime = StartTime.Add( duration );
     Duration = duration;
     int oneSecondRepeats = (int)duration.TotalSeconds + 1;
     if( duration > Hour ) {
         announceIntervalIndex = AnnounceIntervals.Length - 1;
         lastHourAnnounced = (int)duration.TotalHours;
     } else {
         for( int i = 0; i < AnnounceIntervals.Length; i++ ) {
             if( duration <= AnnounceIntervals[i] ) {
                 announceIntervalIndex = i - 1;
                 break;
             }
         }
     }
     task = Scheduler.NewTask( TimerCallback, this );
     Id = Interlocked.Increment( ref timerCounter );
     AddTimerToList( this );
     IsRunning = true;
     task.RunRepeating( TimeSpan.Zero,
                        TimeSpan.FromSeconds( 1 ),
                        oneSecondRepeats );
 }
开发者ID:Blingpancakeman,项目名称:800craft,代码行数:28,代码来源:ChatTimer.cs

示例2: ChatTimer

 ChatTimer( TimeSpan duration, [CanBeNull] string message, [NotNull] string startedBy ) {
     if( startedBy == null ) throw new ArgumentNullException( "startedBy" );
     StartedBy = startedBy;
     Message = message;
     StartTime = DateTime.UtcNow;
     EndTime = StartTime.Add( duration );
     Duration = duration;
     int oneSecondRepeats = (int)duration.TotalSeconds + 1;
     if( duration > Hour ) {
         announceIntervalIndex = AnnounceIntervals.Length - 1;
         lastHourAnnounced = (int)duration.TotalHours;
     } else {
         for( int i = 0; i < AnnounceIntervals.Length; i++ ) {
             if( duration <= AnnounceIntervals[i] ) {
                 announceIntervalIndex = i - 1;
                 break;
             }
         }
     }
     task = Scheduler.NewTask( TimerCallback, this );
     ID = Interlocked.Increment( ref timerCounter );
     AddTimerToList( this );
     IsRunning = true;
     task.RunRepeating( TimeSpan.Zero,
                        TimeSpan.FromSeconds( 1 ),
                        oneSecondRepeats );
     try
     {
         if (!(Directory.Exists("./Timers"))) Directory.CreateDirectory("./Timers");
         string[] output = { "StartDate: " + StartTime.ToString(), "EndDate: " + EndTime.ToString(), "CreatedBy: " + StartedBy, "Message: " + Message };
         File.WriteAllLines("./Timers/" + EndTime.Year.ToString() + "_" + EndTime.Month.ToString() + "_" + EndTime.Day.ToString() + "_" + EndTime.Hour.ToString() + "_" + EndTime.Minute.ToString() + "_" + EndTime.Second.ToString() + ".txt", output);
     }
     catch (Exception ex)
     {
         Player.Console.Message("Timer Writer Has Crashed: {0}", ex);
     }
 }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:37,代码来源:ChatTimer.cs

示例3: Start

 public static void Start()
 {
     world_.Hax = false;
     world_.gameMode = GameMode.FFA; //set the game mode
     delayTask = Scheduler.NewTask(t => world_.Players.Message("&WFFA &fwill be starting in {0} seconds: &WGet ready!", (timeDelay - (DateTime.Now - startTime).ToSeconds())));
     delayTask.RunRepeating(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(10), (timeDelay / 10));
 }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:7,代码来源:FFA.cs

示例4: Start

 public static void Start()
 {
     world_.Hax = false;
     world_.gameMode = GameMode.TeamDeathMatch; //set the game mode
     delayTask = Scheduler.NewTask(t => world_.Players.Message("&WTEAM DEATHMATCH &fwill be starting in {0} seconds: &WGet ready!", timeDelay));
     delayTask.RunRepeating(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(10), 1);
 }
开发者ID:Rhinovex,项目名称:LegendCraft,代码行数:7,代码来源:TeamDeathMatch.cs

示例5: Start

        public static void Start()
        {
            world_.Hax = false;

            //world_.Players.Send(PacketWriter.MakeHackControl(0,0,0,0,0,-1)); Commented out until classicube clients support hax packet
            stopwatch.Reset();
            stopwatch.Start();
            world_.gameMode = GameMode.CaptureTheFlag;
            delayTask = Scheduler.NewTask(t => world_.Players.Message("&WCTF &fwill be starting in {0} seconds: &WGet ready!", (timeDelay - stopwatch.Elapsed.Seconds)));
            delayTask.RunRepeating(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(10), (int)Math.Floor((double)(timeDelay / 10)));//Start task immediately, send message every 10s
            if (stopwatch.Elapsed.Seconds > 11)
            {
                stopwatch.Stop();
            }
        }
开发者ID:EricKilla,项目名称:LegendCraft,代码行数:15,代码来源:CTF.cs


注:本文中的fCraft.SchedulerTask.RunRepeating方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。