优化退出线程

This commit is contained in:
ZouJin 2023-11-20 23:57:54 +08:00
parent 3ad01e4782
commit 2157095823
2 changed files with 25 additions and 11 deletions

View File

@ -356,8 +356,6 @@ namespace VPet_Simulator.Core
public void Dispose()
{
EventTimer.Stop();
MoveTimer.Enabled = false;
EventTimer.Dispose();
MoveTimer.Dispose();
MsgBar.Dispose();

View File

@ -267,9 +267,7 @@ namespace VPet_Simulator.Windows
if (App.MainWindows.Count <= 1)
{
try
{
if (IsSteamUser)
SteamClient.Shutdown();//关掉和Steam的连线
{
if (Core != null && Core.Graph != null)
{
foreach (var igs in Core.Graph.GraphsList.Values)
@ -283,17 +281,18 @@ namespace VPet_Simulator.Windows
}
}
}
if (Main != null)
while (Windows.Count != 0)
{
Main.Dispose();
}
if (winSetting != null)
{
winSetting.Close();
Windows[0].Close();
}
Main?.Dispose();
AutoSaveTimer?.Stop();
MusicTimer?.Stop();
petHelper?.Close();
winSetting?.Close();
winBetterBuy?.Close();
if (IsSteamUser)
SteamClient.Shutdown();//关掉和Steam的连线
if (notifyIcon != null)
{
notifyIcon.Visible = false;
@ -310,10 +309,27 @@ namespace VPet_Simulator.Windows
}
else
{
if (Core != null && Core.Graph != null)
{
foreach (var igs in Core.Graph.GraphsList.Values)
{
foreach (var ig2 in igs.Values)
{
foreach (var ig3 in ig2)
{
ig3.Stop();
}
}
}
}
while (Windows.Count != 0)
{
Windows[0].Close();
}
Main?.Dispose();
AutoSaveTimer?.Stop();
MusicTimer?.Stop();
petHelper?.Close();
winSetting?.Close();
winBetterBuy?.Close();
App.MainWindows.Remove(this);