diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index 8c677d1c3..2d805ab91 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -26,7 +26,7 @@ jobs:
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 5.0.301
+ dotnet-version: 5.0.302
- name: Build
run: ./publish.cmd
- name: Test
diff --git a/Projects/Benchmarks/Benchmarks.csproj b/Projects/Benchmarks/Benchmarks.csproj
index e0ab71eea..cd7d4a26c 100644
--- a/Projects/Benchmarks/Benchmarks.csproj
+++ b/Projects/Benchmarks/Benchmarks.csproj
@@ -9,7 +9,7 @@
true
-
+
diff --git a/Projects/Server.Tests/Fixtures/ServerFixture.cs b/Projects/Server.Tests/Fixtures/ServerFixture.cs
index f286d1051..fa4669c32 100644
--- a/Projects/Server.Tests/Fixtures/ServerFixture.cs
+++ b/Projects/Server.Tests/Fixtures/ServerFixture.cs
@@ -7,6 +7,8 @@ namespace Server.Tests
// Global setup
static ServerFixture()
{
+ Core.LoopContext = new EventLoopContext();
+
Core.Expansion = Expansion.EJ;
// Load Configurations
diff --git a/Projects/Server.Tests/Tests/Timer/TimerTests.cs b/Projects/Server.Tests/Tests/Timer/TimerTests.cs
index d7a005626..30fdbcd7a 100644
--- a/Projects/Server.Tests/Tests/Timer/TimerTests.cs
+++ b/Projects/Server.Tests/Tests/Timer/TimerTests.cs
@@ -25,8 +25,7 @@ namespace Server.Tests
Timer.Init(timerTicks.Ticks);
- var timer = Timer.DelayCall(TimeSpan.FromMilliseconds(ticks), action);
- timer.Start();
+ Timer.StartTimer(TimeSpan.FromMilliseconds(ticks), action);
var tickCount = expectedTicks / 8;
@@ -53,8 +52,7 @@ namespace Server.Tests
Timer.Init(timerTicks.Ticks);
- var timer = Timer.DelayCall(TimeSpan.FromMilliseconds(delay), TimeSpan.FromMilliseconds(interval), count, action);
- timer.Start();
+ Timer.StartTimer(TimeSpan.FromMilliseconds(delay), TimeSpan.FromMilliseconds(interval), count, action);
var tickCount = (expectedDelayTicks + (expectedIntervalTicks * count - 1)) / 8;
diff --git a/Projects/Server/EventLoopTasks.cs b/Projects/Server/EventLoopTasks.cs
index a96d7aa53..3ead229cb 100644
--- a/Projects/Server/EventLoopTasks.cs
+++ b/Projects/Server/EventLoopTasks.cs
@@ -32,6 +32,8 @@ namespace Server
public override SynchronizationContext CreateCopy() => new EventLoopContext();
+ public void Post(Action d) => _queue.Enqueue(d);
+
public override void Post(SendOrPostCallback d, object state) => _queue.Enqueue(() => d(state));
public override void Send(SendOrPostCallback d, object state)
diff --git a/Projects/Server/IEntity.cs b/Projects/Server/IEntity.cs
index 827eb28ae..4dbb61470 100644
--- a/Projects/Server/IEntity.cs
+++ b/Projects/Server/IEntity.cs
@@ -108,7 +108,7 @@ namespace Server
public void Deserialize(IGenericReader reader)
{
// Should not actually be saved
- Timer.DelayCall(Delete);
+ Timer.StartTimer(Delete);
}
public void Serialize(IGenericWriter writer)
diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs
index cffee465a..c54d6ae40 100644
--- a/Projects/Server/Items/Item.cs
+++ b/Projects/Server/Items/Item.cs
@@ -3027,7 +3027,7 @@ namespace Server
if (HeldBy != null)
{
- Timer.DelayCall(FixHolding_Sandbox);
+ Timer.StartTimer(FixHolding_Sandbox);
}
// if (version < 9)
diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs
index 6944fc26d..01e46e8eb 100644
--- a/Projects/Server/Main.cs
+++ b/Projects/Server/Main.cs
@@ -47,7 +47,7 @@ namespace Server
private static int _itemCount;
private static int _mobileCount;
- private static EventLoopContext _eventLoopContext;
+ public static EventLoopContext LoopContext { get; set; }
private static readonly Type[] _serialTypeArray = { typeof(Serial) };
@@ -366,9 +366,9 @@ namespace Server
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
- _eventLoopContext = new EventLoopContext();
+ LoopContext = new EventLoopContext();
- SynchronizationContext.SetSynchronizationContext(_eventLoopContext);
+ SynchronizationContext.SetSynchronizationContext(LoopContext);
foreach (var a in args)
{
@@ -505,7 +505,9 @@ namespace Server
events += NetState.Slice();
// Execute captured post-await methods (like Timer.Pause)
- events += _eventLoopContext.ExecuteTasks();
+ events += LoopContext.ExecuteTasks();
+
+ Timer.CheckTimerPool(); // Check for pool depletion so we can async refill it.
_tickCount = 0;
_now = DateTime.MinValue;
diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs
index 0e79e03ba..aee6309fa 100644
--- a/Projects/Server/Mobiles/Mobile.cs
+++ b/Projects/Server/Mobiles/Mobile.cs
@@ -454,7 +454,7 @@ namespace Server
private List