mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-25 18:46:58 +01:00
Added more proper logging of background thread exceptions
This commit is contained in:
parent
4ec4eb830f
commit
529adf9f27
@ -128,6 +128,7 @@ namespace DS4WinWPF
|
|||||||
|
|
||||||
logHolder = new LoggerHolder(rootHub);
|
logHolder = new LoggerHolder(rootHub);
|
||||||
DispatcherUnhandledException += App_DispatcherUnhandledException;
|
DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
Logger logger = logHolder.Logger;
|
Logger logger = logHolder.Logger;
|
||||||
string version = DS4Windows.Global.exeversion;
|
string version = DS4Windows.Global.exeversion;
|
||||||
logger.Info($"DS4Windows version {version}");
|
logger.Info($"DS4Windows version {version}");
|
||||||
@ -173,6 +174,26 @@ namespace DS4WinWPF
|
|||||||
window.LateChecks(parser);
|
window.LateChecks(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Current.Dispatcher.CheckAccess())
|
||||||
|
{
|
||||||
|
Logger logger = logHolder.Logger;
|
||||||
|
Exception exp = e.ExceptionObject as Exception;
|
||||||
|
logger.Error($"Thread App Crashed with message {exp.Message}");
|
||||||
|
logger.Error(exp.ToString());
|
||||||
|
//LogManager.Flush();
|
||||||
|
//LogManager.Shutdown();
|
||||||
|
if (e.IsTerminating)
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
CleanShutdown(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("App Crashed");
|
//Console.WriteLine("App Crashed");
|
||||||
@ -450,7 +471,7 @@ namespace DS4WinWPF
|
|||||||
CleanShutdown();
|
CleanShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanShutdown()
|
private void CleanShutdown(int exitCode = 0)
|
||||||
{
|
{
|
||||||
if (runShutdown)
|
if (runShutdown)
|
||||||
{
|
{
|
||||||
@ -458,7 +479,8 @@ namespace DS4WinWPF
|
|||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
rootHub.Stop();
|
if (rootHub.running)
|
||||||
|
rootHub.Stop();
|
||||||
}).Wait();
|
}).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,6 +503,11 @@ namespace DS4WinWPF
|
|||||||
|
|
||||||
LogManager.Flush();
|
LogManager.Flush();
|
||||||
LogManager.Shutdown();
|
LogManager.Shutdown();
|
||||||
|
|
||||||
|
if (exitCode != 0)
|
||||||
|
{
|
||||||
|
Current.Shutdown(exitCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,8 +608,10 @@ namespace DS4Windows
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
exitInputThread = true;
|
exitInputThread = true;
|
||||||
//ds4Input.Abort();
|
if (ds4Input.ThreadState.HasFlag(System.Threading.ThreadState.WaitSleepJoin))
|
||||||
ds4Input.Join();
|
ds4Input.Interrupt();
|
||||||
|
else
|
||||||
|
ds4Input.Join();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user