當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。