Targets .NET Core 3.0 (#39)
This commit is contained in:
parent
0993c03b70
commit
08bf44af9a
125 changed files with 1473 additions and 14244 deletions
|
|
@ -22,6 +22,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Server.Diagnostics;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -587,5 +588,31 @@ namespace Server
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private class DelayTaskTimer : Timer
|
||||
{
|
||||
private TaskCompletionSource<DelayTaskTimer> m_TaskCompleter;
|
||||
|
||||
public Task Task { get { return m_TaskCompleter.Task; } }
|
||||
|
||||
public DelayTaskTimer(TimeSpan delay) : base(delay)
|
||||
{
|
||||
m_TaskCompleter = new TaskCompletionSource<DelayTaskTimer>();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_TaskCompleter.SetResult(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static Task Pause(int ms) => Pause(TimeSpan.FromMilliseconds(ms));
|
||||
|
||||
public static Task Pause(TimeSpan ms)
|
||||
{
|
||||
DelayTaskTimer t = new DelayTaskTimer(ms);
|
||||
t.Start();
|
||||
return t.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue