ensure SMAPI resources are disposed on exit (#268)
This commit is contained in:
parent
07197fac9d
commit
8ec607ba3c
|
@ -16,7 +16,8 @@ See [log](https://github.com/Pathoschild/SMAPI/compare/1.9...1.10).
|
|||
For players:
|
||||
* Added support for Stardew Valley 1.2 beta.
|
||||
* Added logic to rewrite many mods for compatibility with game updates, though some mods may still need an update.
|
||||
* Fixed some players getting `SEHException` errors.
|
||||
* Fixed `SEHException` errors affecting some players.
|
||||
* Fixed issue where SMAPI didn't unlock some files on exit.
|
||||
* Fixed rare issue where the installer would crash trying to delete a bundled mod from `%appdata%`.
|
||||
* Improved TrainerMod commands:
|
||||
* Added `world_setyear` to change the current year.
|
||||
|
|
|
@ -22,7 +22,7 @@ using Monitor = StardewModdingAPI.Framework.Monitor;
|
|||
namespace StardewModdingAPI
|
||||
{
|
||||
/// <summary>The main entry point for SMAPI, responsible for hooking into and launching the game.</summary>
|
||||
internal class Program
|
||||
internal class Program : IDisposable
|
||||
{
|
||||
/*********
|
||||
** Properties
|
||||
|
@ -87,8 +87,8 @@ namespace StardewModdingAPI
|
|||
logPath = Constants.DefaultLogPath;
|
||||
|
||||
// load SMAPI
|
||||
new Program(writeToConsole, logPath)
|
||||
.LaunchInteractively();
|
||||
using (Program program = new Program(writeToConsole, logPath))
|
||||
program.RunInteractively();
|
||||
}
|
||||
|
||||
/// <summary>Construct an instance.</summary>
|
||||
|
@ -101,7 +101,7 @@ namespace StardewModdingAPI
|
|||
}
|
||||
|
||||
/// <summary>Launch SMAPI.</summary>
|
||||
public void LaunchInteractively()
|
||||
public void RunInteractively()
|
||||
{
|
||||
// initialise SMAPI
|
||||
try
|
||||
|
@ -204,6 +204,15 @@ namespace StardewModdingAPI
|
|||
return this.GetSecondaryMonitor(modName);
|
||||
}
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.LogFile?.Dispose();
|
||||
this.ConsoleManager?.Dispose();
|
||||
this.CancellationTokenSource?.Dispose();
|
||||
this.GameInstance?.Dispose();
|
||||
}
|
||||
|
||||
|
||||
/*********
|
||||
** Private methods
|
||||
|
|
Loading…
Reference in New Issue