mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
[Refactor] Update Task.Run usage to await and discard returned tasks.
Fixes some race conditions.
This commit is contained in:
@@ -390,8 +390,8 @@ resharper_loop_can_be_converted_to_query_highlighting
|
||||
resharper_loop_can_be_partly_converted_to_query_highlighting = warning
|
||||
resharper_member_can_be_file_local_highlighting = warning
|
||||
resharper_member_can_be_internal_highlighting = warning
|
||||
resharper_member_can_be_made_static_global_highlighting = warning
|
||||
resharper_member_can_be_made_static_local_highlighting = warning
|
||||
resharper_member_can_be_made_static_global_highlighting = none
|
||||
resharper_member_can_be_made_static_local_highlighting = none
|
||||
resharper_member_can_be_private_global_highlighting = warning
|
||||
resharper_member_can_be_private_local_highlighting = warning
|
||||
resharper_member_can_be_protected_global_highlighting = warning
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Vfs : IDisposable
|
||||
MountPoint = mountPoint
|
||||
};
|
||||
|
||||
Task.Run(() =>
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
_fuse.Start();
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ public class FileExporter
|
||||
if(_filesByMachine.Count == 0)
|
||||
{
|
||||
_machinePosition++;
|
||||
Task.Run(CompressNextMachine);
|
||||
_ = Task.Run(CompressNextMachine);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ public sealed class AboutViewModel : ViewModelBase
|
||||
|
||||
Assemblies = [];
|
||||
|
||||
// TODO: They do not load in time
|
||||
Task.Run(() =>
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName))
|
||||
{
|
||||
|
||||
@@ -145,6 +145,6 @@ public sealed class ExportDatViewModel : ViewModelBase
|
||||
|
||||
if(!File.Exists(compressedDatPath)) _view.Close();
|
||||
|
||||
Task.Run(() => _worker.DecompressFile(compressedDatPath, _outPath));
|
||||
_ = Task.Run(() => _worker.DecompressFile(compressedDatPath, _outPath));
|
||||
}
|
||||
}
|
||||
@@ -260,6 +260,6 @@ public sealed class ExportRomsViewModel : ViewModelBase
|
||||
|
||||
ProgressVisible = true;
|
||||
|
||||
Task.Run(worker.Export);
|
||||
_ = Task.Run(worker.Export);
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,9 @@ public sealed class ImportDatFolderViewModel : ViewModelBase
|
||||
|
||||
internal void OnOpened() => RefreshFiles();
|
||||
|
||||
void RefreshFiles() => Task.Run(() =>
|
||||
void RefreshFiles()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
@@ -262,6 +264,7 @@ public sealed class ImportDatFolderViewModel : ViewModelBase
|
||||
CanStart = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void ExecuteCloseCommand() => _view.Close();
|
||||
|
||||
@@ -307,7 +310,7 @@ public sealed class ImportDatFolderViewModel : ViewModelBase
|
||||
_worker.SetProgressBounds += OnWorkerOnSetProgressBounds;
|
||||
_worker.WorkFinished += OnWorkerOnWorkFinished;
|
||||
_worker.RomSetAdded += RomSetAdded;
|
||||
Task.Run(_worker.Import);
|
||||
_ = Task.Run(_worker.Import);
|
||||
}
|
||||
|
||||
void OnWorkerOnWorkFinished(object sender, MessageEventArgs args) => Dispatcher.UIThread.Post(() =>
|
||||
|
||||
@@ -161,7 +161,7 @@ public sealed class ImportDatViewModel : ViewModelBase
|
||||
{
|
||||
ProgressVisible = true;
|
||||
_worker.RomSetAdded += RomSetAdded;
|
||||
Task.Run(_worker.Import);
|
||||
_ = Task.Run(_worker.Import);
|
||||
}
|
||||
|
||||
public event EventHandler<RomSetEventArgs> RomSetAdded;
|
||||
|
||||
@@ -244,7 +244,7 @@ public sealed class ImportRomFolderViewModel : ViewModelBase
|
||||
worker.Finished += OnWorkerOnFinished;
|
||||
worker.ImportedRom += OnWorkerOnImportedRom;
|
||||
|
||||
Task.Run(() => worker.ProcessPath(FolderPath, true, RecurseArchivesChecked));
|
||||
_ = Task.Run(() => worker.ProcessPath(FolderPath, true, RecurseArchivesChecked));
|
||||
}
|
||||
|
||||
void OnWorkerOnImportedRom(object sender, ImportedRomItemEventArgs args) =>
|
||||
|
||||
@@ -149,7 +149,7 @@ public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
var dialog = new About();
|
||||
dialog.DataContext = new AboutViewModel(dialog);
|
||||
dialog.ShowDialog(_view);
|
||||
_ = dialog.ShowDialog(_view);
|
||||
}
|
||||
|
||||
async void ExecuteImportDatCommand()
|
||||
|
||||
@@ -55,7 +55,9 @@ public sealed class RemoveDatViewModel : ViewModelBase
|
||||
set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
|
||||
}
|
||||
|
||||
internal void OnOpened() => Task.Run(() =>
|
||||
internal void OnOpened()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
|
||||
@@ -104,3 +106,4 @@ public sealed class RemoveDatViewModel : ViewModelBase
|
||||
Dispatcher.UIThread.Post(_view.Close);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public sealed class SettingsViewModel : ViewModelBase
|
||||
worker.FinishedWithText += CheckUnArFinished;
|
||||
worker.FailedWithText += CheckUnArFailed;
|
||||
|
||||
Task.Run(() => worker.CheckUnAr(UnArPath));
|
||||
_ = Task.Run(() => worker.CheckUnAr(UnArPath));
|
||||
}
|
||||
|
||||
async void CheckUnArFailed(object sender, ErrorEventArgs args)
|
||||
|
||||
@@ -193,7 +193,9 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
|
||||
internal void OnOpened() => Dispatcher.UIThread.Post(LoadSettings);
|
||||
|
||||
void LoadSettings() => Task.Run(() =>
|
||||
void LoadSettings()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -207,6 +209,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
Dispatcher.UIThread.Post(FailedLoadingSettings);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FailedLoadingSettings()
|
||||
{
|
||||
@@ -215,7 +218,9 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
ExitVisible = true;
|
||||
}
|
||||
|
||||
void CheckUnAr() => Task.Run(() =>
|
||||
void CheckUnAr()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
LoadingSettingsUnknown = false;
|
||||
LoadingSettingsOk = true;
|
||||
@@ -233,6 +238,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
Dispatcher.UIThread.Post(FailedCheckUnAr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FailedCheckUnAr()
|
||||
{
|
||||
@@ -246,7 +252,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
CheckingUnArUnknown = false;
|
||||
CheckingUnArOk = true;
|
||||
|
||||
Task.Run(() =>
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -278,7 +284,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
LoadingDatabaseUnknown = false;
|
||||
LoadingDatabaseOk = true;
|
||||
|
||||
Task.Run(() =>
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -308,7 +314,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
|
||||
MigratingDatabaseUnknown = false;
|
||||
MigratingDatabaseOk = true;
|
||||
|
||||
Task.Run(() =>
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -128,7 +128,9 @@ public sealed class UpdateStatsViewModel : ViewModelBase
|
||||
public string CloseLabel => Localization.CloseLabel;
|
||||
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
|
||||
|
||||
internal void OnOpened() => Task.Run(() =>
|
||||
internal void OnOpened()
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
|
||||
@@ -261,6 +263,7 @@ public sealed class UpdateStatsViewModel : ViewModelBase
|
||||
CanClose = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void ExecuteCloseCommand() => _view.Close();
|
||||
}
|
||||
Reference in New Issue
Block a user