Unfix async Task where it doesn't work.

This commit is contained in:
2022-11-14 09:41:19 +00:00
parent 5a1a7ad39a
commit f90cc6593f
3 changed files with 49 additions and 54 deletions

View File

@@ -679,13 +679,11 @@ public sealed class ImageConvertViewModel : ViewModelBase
foreach(MediaTagType mediaTag in _inputFormat.Info.ReadableMediaTags.Where(mediaTag => foreach(MediaTagType mediaTag in _inputFormat.Info.ReadableMediaTags.Where(mediaTag =>
!outputFormat.SupportedMediaTags.Contains(mediaTag) && !ForceChecked)) !outputFormat.SupportedMediaTags.Contains(mediaTag) && !ForceChecked))
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Converting image will lose media tag { $"Converting image will lose media tag {mediaTag}, not continuing...",
mediaTag icon: Icon.Error).
}, not continuing...", ShowDialog(_view));
icon: Icon.Error).
ShowDialog(_view));
return; return;
} }
@@ -705,11 +703,11 @@ public sealed class ImageConvertViewModel : ViewModelBase
continue; continue;
} }
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Converting image will lose sector tag {sectorTag}, not continuing...", $"Converting image will lose sector tag {sectorTag}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
ShowDialog(_view)); ShowDialog(_view));
return; return;
} }
@@ -758,13 +756,11 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(!outputFormat.Create(DestinationText, _inputFormat.Info.MediaType, parsedOptions, _inputFormat.Info.Sectors, if(!outputFormat.Create(DestinationText, _inputFormat.Info.MediaType, parsedOptions, _inputFormat.Info.Sectors,
_inputFormat.Info.SectorSize)) _inputFormat.Info.SectorSize))
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat. $"Error {outputFormat.ErrorMessage} creating output image.",
ErrorMessage icon: Icon.Error).
} creating output image.", ShowDialog(_view));
icon: Icon.Error).
ShowDialog(_view));
AaruConsole.ErrorWriteLine("Error {0} creating output image.", outputFormat.ErrorMessage); AaruConsole.ErrorWriteLine("Error {0} creating output image.", outputFormat.ErrorMessage);
@@ -806,11 +802,11 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(ForceChecked != true) if(ForceChecked != true)
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} setting metadata, not continuing...", $"Error {outputFormat.ErrorMessage} setting metadata, not continuing...",
icon: Icon.Error). icon: Icon.Error).
ShowDialog(_view)); ShowDialog(_view));
AaruConsole.ErrorWriteLine("not continuing..."); AaruConsole.ErrorWriteLine("not continuing...");
@@ -835,11 +831,11 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(!outputOptical.SetTracks(tracks)) if(!outputOptical.SetTracks(tracks))
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} sending tracks list to output image.", $"Error {outputFormat.ErrorMessage} sending tracks list to output image.",
icon: Icon.Error). icon: Icon.Error).
ShowDialog(_view)); ShowDialog(_view));
AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", outputFormat.ErrorMessage); AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", outputFormat.ErrorMessage);
@@ -881,7 +877,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
{ {
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await Dispatcher.UIThread.InvokeAsync(action: async () =>
await MessageBoxManager. await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} writing media tag, not continuing...", $"Error {outputFormat.ErrorMessage} writing media tag, not continuing...",
@@ -892,7 +888,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await Dispatcher.UIThread.InvokeAsync(action: async () =>
await MessageBoxManager. await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading media tag, not continuing...", $"Error {errno} reading media tag, not continuing...",
@@ -985,7 +981,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...", $"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error).ShowDialog(_view)); icon: Icon.Error).ShowDialog(_view));
@@ -1018,7 +1014,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...", $"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error).ShowDialog(_view)); icon: Icon.Error).ShowDialog(_view));
@@ -1041,7 +1037,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", $"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...",
icon: Icon.Error).ShowDialog(_view)); icon: Icon.Error).ShowDialog(_view));
@@ -1199,7 +1195,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...", $"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
@@ -1251,7 +1247,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...", $"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
@@ -1275,7 +1271,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", $"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...",
icon: Icon.Error).ShowDialog(_view)); icon: Icon.Error).ShowDialog(_view));
@@ -1380,7 +1376,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...", $"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
@@ -1414,7 +1410,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading sector {doneSectors}, not continuing...", $"Error {errno} reading sector {doneSectors}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
@@ -1435,7 +1431,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...", $"Error {outputFormat.ErrorMessage} writing sector {doneSectors}, not continuing...",
icon: Icon.Error).ShowDialog(_view)); icon: Icon.Error).ShowDialog(_view));
@@ -1510,7 +1506,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await Dispatcher.UIThread.InvokeAsync(action: async () =>
await MessageBoxManager. await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading tag, not continuing...", $"Error {errno} reading tag, not continuing...",
@@ -1533,7 +1529,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await Dispatcher.UIThread.InvokeAsync(action: async () =>
await MessageBoxManager. await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} writing tag, not continuing...", $"Error {outputFormat.ErrorMessage} writing tag, not continuing...",
@@ -1591,7 +1587,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {errno} reading tag for sector {doneSectors}, not continuing...", $"Error {errno} reading tag for sector {doneSectors}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
@@ -1611,7 +1607,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
} }
else else
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} writing tag for sector {doneSectors}, not continuing...", $"Error {outputFormat.ErrorMessage} writing tag for sector {doneSectors}, not continuing...",
icon: Icon.Error). icon: Icon.Error).
@@ -1676,7 +1672,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(_cancel) if(_cancel)
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await Dispatcher.UIThread.InvokeAsync(action: async () =>
{ {
await MessageBoxManager. await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "Operation canceled, the output file is not correct.", GetMessageBoxStandardWindow("Error", "Operation canceled, the output file is not correct.",
@@ -1692,16 +1688,16 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(!outputFormat.Close()) if(!outputFormat.Close())
{ {
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await MessageBoxManager. await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandardWindow("Error", GetMessageBoxStandardWindow("Error",
$"Error {outputFormat.ErrorMessage} closing output image... Contents are not correct.", $"Error {outputFormat.ErrorMessage} closing output image... Contents are not correct.",
icon: Icon.Error). icon: Icon.Error).
ShowDialog(_view)); ShowDialog(_view));
return; return;
} }
await Dispatcher.UIThread.InvokeAsync(action: async Task() => await Dispatcher.UIThread.InvokeAsync(action: async () =>
{ {
await MessageBoxManager.GetMessageBoxStandardWindow(warning ? "Warning" : "Conversion success", await MessageBoxManager.GetMessageBoxStandardWindow(warning ? "Warning" : "Conversion success",
warning warning

View File

@@ -38,7 +38,6 @@ using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.Reactive; using System.Reactive;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.Console; using Aaru.Console;
using Aaru.Core; using Aaru.Core;
@@ -308,7 +307,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
WholeDiscChecked = false; WholeDiscChecked = false;
} }
var thread = new Thread(async Task() => var thread = new Thread(async () =>
{ {
if(SeparatedTracksChecked) if(SeparatedTracksChecked)
{ {

View File

@@ -576,7 +576,7 @@ public sealed class MediaScanViewModel : ViewModelBase
}); });
[SuppressMessage("ReSharper", "AsyncVoidMethod")] [SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void StoppingErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(action: async Task() => async void StoppingErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(action: async () =>
{ {
ProgressText = text; ProgressText = text;