本文整理汇总了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 );
}
示例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);
}
}
示例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));
}
示例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);
}
示例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();
}
}