Bug fix for exit app

pull/4917/head
2dust 2024-03-30 15:26:12 +08:00
parent bac13e8b71
commit bb3a04a9c8
2 changed files with 17 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using System.Windows;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;
using v2rayN.Handler;
using v2rayN.Model;
@ -81,5 +82,12 @@ namespace v2rayN
{
Logging.SaveLog("TaskScheduler_UnobservedTaskException", e.Exception);
}
protected override void OnExit(ExitEventArgs e)
{
Logging.SaveLog("OnExit");
base.OnExit(e);
Process.GetCurrentProcess().Kill();
}
}
}

View File

@ -597,7 +597,7 @@ namespace v2rayN.ViewModels
private void OnProgramStarted(object state, bool timeout)
{
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
ShowHideWindow(true);
}));
@ -638,7 +638,7 @@ namespace v2rayN.ViewModels
{
try
{
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
if (!_showInTaskbar)
{
@ -684,7 +684,7 @@ namespace v2rayN.ViewModels
private void UpdateSpeedtestHandler(string indexId, string delay, string speed)
{
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
SetTestResult(indexId, delay, speed);
}));
@ -747,7 +747,6 @@ namespace v2rayN.ViewModels
{
Logging.SaveLog("MyAppExit Begin");
StorageUI();
ConfigHandler.SaveConfig(_config);
//HttpProxyHandle.CloseHttpAgent(config);
@ -772,7 +771,6 @@ namespace v2rayN.ViewModels
finally
{
Application.Current.Shutdown();
Environment.Exit(0);
}
}
@ -848,7 +846,7 @@ namespace v2rayN.ViewModels
}).OrderBy(t => t.sort).ToList();
_lstProfile = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstModel));
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
_profileItems.Clear();
_profileItems.AddRange(lstModel);
@ -1186,7 +1184,7 @@ namespace v2rayN.ViewModels
(new UpdateHandle()).RunAvailabilityCheck((bool success, string msg) =>
{
_noticeHandler?.SendMessage(msg, true);
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
if (!_showInTaskbar)
{
@ -1509,7 +1507,7 @@ namespace v2rayN.ViewModels
{
TestServerAvailability();
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
BlReloadEnabled = true;
}));
@ -1559,7 +1557,7 @@ namespace v2rayN.ViewModels
SysProxyHandle.UpdateSysProxy(_config, _config.tunModeItem.enableTun ? true : false);
_noticeHandler?.SendMessage(ResUI.TipChangeSystemProxy + _config.sysProxyType.ToString(), true);
Application.Current.Dispatcher.Invoke((Action)(() =>
Application.Current?.Dispatcher.Invoke((Action)(() =>
{
BlSystemProxyClear = (type == ESysProxyType.ForcedClear);
BlSystemProxySet = (type == ESysProxyType.ForcedChange);
@ -1708,10 +1706,6 @@ namespace v2rayN.ViewModels
}
}
private void StorageUI()
{
}
private void BindingUI()
{
ColorModeDark = _config.uiItem.colorModeDark;
@ -1873,7 +1867,7 @@ namespace v2rayN.ViewModels
.Delay(TimeSpan.FromSeconds(1))
.Subscribe(x =>
{
Application.Current.Dispatcher.Invoke(() =>
Application.Current?.Dispatcher.Invoke(() =>
{
ShowHideWindow(false);
});