diff --git a/DS4Windows/DS4Control/Util.cs b/DS4Windows/DS4Control/Util.cs index 923aa17..bd784fe 100644 --- a/DS4Windows/DS4Control/Util.cs +++ b/DS4Windows/DS4Control/Util.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Security; +using System.Threading.Tasks; using System.Text; namespace DS4Windows @@ -154,5 +155,16 @@ namespace DS4Windows } catch { } } + + public static void LogAssistBackgroundTask(Task task) + { + task.ContinueWith((t) => + { + if (t.IsFaulted) + { + AppLogger.LogToGui(t.Exception.ToString(), true); + } + }); + } } } diff --git a/DS4Windows/DS4Forms/MainWindow.xaml.cs b/DS4Windows/DS4Forms/MainWindow.xaml.cs index 6832a5c..f1d9dc5 100644 --- a/DS4Windows/DS4Forms/MainWindow.xaml.cs +++ b/DS4Windows/DS4Forms/MainWindow.xaml.cs @@ -124,7 +124,7 @@ namespace DS4WinWPF.DS4Forms public void LateChecks(ArgumentParser parser) { - Task.Run(() => + Task tempTask = Task.Run(() => { CheckDrivers(); if (!parser.Stop) @@ -136,7 +136,9 @@ namespace DS4WinWPF.DS4Forms UpdateTheUpdater(); }); - Task.Delay(100).ContinueWith((t) => + Util.LogAssistBackgroundTask(tempTask); + + tempTask = Task.Delay(100).ContinueWith((t) => { int checkwhen = Global.CheckWhen; if (checkwhen > 0 && DateTime.Now >= Global.LastChecked + TimeSpan.FromHours(checkwhen)) @@ -147,6 +149,7 @@ namespace DS4WinWPF.DS4Forms Global.LastChecked = DateTime.Now; } }); + Util.LogAssistBackgroundTask(tempTask); } private void DownloadUpstreamVersionInfo()