diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-07-06 19:37:52 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-07-06 19:37:52 -0400 |
commit | 2421fa3fa10b15ebf7bbe2e1893311c27a33b6fd (patch) | |
tree | eee29d49d8e4a88cf4cc54f528c34d88781dd177 /src/SMAPI | |
parent | 850cb505870a3426f8fde1bee498fdb8e29a0ee3 (diff) | |
download | SMAPI-2421fa3fa10b15ebf7bbe2e1893311c27a33b6fd.tar.gz SMAPI-2421fa3fa10b15ebf7bbe2e1893311c27a33b6fd.tar.bz2 SMAPI-2421fa3fa10b15ebf7bbe2e1893311c27a33b6fd.zip |
run new-day task synchronously
This avoids issues when mod events are called asynchronously (like IAssetLoaders loading PNG tilesheets on season change while the game is drawing).
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Framework/SGame.cs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index 240e9a97..d3865316 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading; +using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; @@ -223,7 +224,7 @@ namespace StardewModdingAPI.Framework return; } - // Run loaders synchronously to avoid issues due to mod events triggering + // Run async tasks synchronously to avoid issues due to mod events triggering // concurrently with game code. if (Game1.currentLoader != null) { @@ -233,6 +234,12 @@ namespace StardewModdingAPI.Framework Game1.currentLoader = null; this.Monitor.Log("Game loader done.", LogLevel.Trace); } + if (Game1._newDayTask?.Status == TaskStatus.Created) + { + this.Monitor.Log("New day task synchronising...", LogLevel.Trace); + Game1._newDayTask.RunSynchronously(); + this.Monitor.Log("New day task done.", LogLevel.Trace); + } // While a background task is in progress, the game may make changes to the game // state while mods are running their code. This is risky, because data changes can |