Fix async void when it should be async Task, ignore the rest.

This commit is contained in:
2022-11-14 01:38:50 +00:00
parent a9726d0661
commit 8a511d0d44
6 changed files with 93 additions and 51 deletions

View File

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

View File

@@ -34,16 +34,17 @@ namespace Aaru.Gui.ViewModels.Windows;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reactive;
using System.Threading;
using System.Threading.Tasks;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Core;
using Aaru.Gui.Models;
using Avalonia.Controls;
using Avalonia.Threading;
using JetBrains.Annotations;
using ReactiveUI;
public sealed class ImageEntropyViewModel : ViewModelBase
@@ -277,7 +278,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
}
[NotNull]
[JetBrains.Annotations.NotNull]
public string Title => "Calculating entropy";
public ObservableCollection<TrackEntropyModel> TrackEntropy { get; }
public ReactiveCommand<Unit, Unit> StartCommand { get; }
@@ -307,7 +308,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
WholeDiscChecked = false;
}
var thread = new Thread(async () =>
var thread = new Thread(async Task() =>
{
if(SeparatedTracksChecked)
{
@@ -381,6 +382,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
void EndProgress2() => Progress2Visible = false;
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
@@ -399,6 +401,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
ProgressValue = current;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Text = text;

View File

@@ -34,6 +34,7 @@ namespace Aaru.Gui.ViewModels.Windows;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reactive;
using System.Text;
@@ -219,6 +220,7 @@ public sealed class ImageSidecarViewModel : ViewModelBase
void ExecuteStartCommand() => new Thread(DoWork).Start();
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork()
{
// Prepare UI
@@ -262,11 +264,13 @@ public sealed class ImageSidecarViewModel : ViewModelBase
Statistics.AddCommand("create-sidecar");
}
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Text = text;
@@ -276,16 +280,19 @@ public sealed class ImageSidecarViewModel : ViewModelBase
Progress2Value = current;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = true;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
@@ -295,11 +302,13 @@ public sealed class ImageSidecarViewModel : ViewModelBase
ProgressValue = current;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
StatusText = text;

View File

@@ -35,6 +35,7 @@ namespace Aaru.Gui.ViewModels.Windows;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
using System.Threading;
using Aaru.CommonTypes.Interfaces;
@@ -343,6 +344,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase
new Thread(DoWork).Start();
}
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork()
{
bool formatHasTracks;

View File

@@ -35,6 +35,7 @@ namespace Aaru.Gui.ViewModels.Windows;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reactive;
@@ -817,6 +818,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
new Thread(DoWork).Start();
}
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork()
{
_dumper.UpdateStatus += UpdateStatus;
@@ -845,11 +847,13 @@ public sealed class MediaDumpViewModel : ViewModelBase
Progress2Visible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Text = text;
@@ -859,16 +863,19 @@ public sealed class MediaDumpViewModel : ViewModelBase
Progress2Value = current;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = true;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
@@ -878,17 +885,20 @@ public sealed class MediaDumpViewModel : ViewModelBase
ProgressValue = current;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void PulseProgress(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
ProgressIndeterminate = true;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void StoppingErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(async () =>
{
ErrorMessage(text);
@@ -899,11 +909,13 @@ public sealed class MediaDumpViewModel : ViewModelBase
await WorkFinished();
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void ErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
Log += text + Environment.NewLine;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
Log += text + Environment.NewLine;

View File

@@ -33,6 +33,7 @@
namespace Aaru.Gui.ViewModels.Windows;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
using System.Threading;
using System.Threading.Tasks;
@@ -321,6 +322,7 @@ public sealed class MediaScanViewModel : ViewModelBase
}
// TODO: Allow to save MHDD and ImgBurn log files
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork()
{
if(_devicePath.Length == 2 &&
@@ -421,6 +423,7 @@ public sealed class MediaScanViewModel : ViewModelBase
await WorkFinished();
}
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void ScanSpeed(ulong sector, double currentSpeed) => await Dispatcher.UIThread.InvokeAsync(() =>
{
if(ChartPoints.Count == 0)
@@ -432,6 +435,7 @@ public sealed class MediaScanViewModel : ViewModelBase
MaxY = currentSpeed + currentSpeed / 10d;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitBlockMap(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
@@ -542,11 +546,13 @@ public sealed class MediaScanViewModel : ViewModelBase
ProgressVisible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
@@ -556,18 +562,21 @@ public sealed class MediaScanViewModel : ViewModelBase
ProgressValue = current;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void PulseProgress(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
ProgressIndeterminate = true;
});
async void StoppingErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(action: async () =>
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void StoppingErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(action: async Task() =>
{
ProgressText = text;
@@ -577,11 +586,13 @@ public sealed class MediaScanViewModel : ViewModelBase
WorkFinished();
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void OnScanUnreadable(ulong sector) => await Dispatcher.UIThread.InvokeAsync(() =>
{
_localResults.Errored += _blocksToRead;
@@ -589,6 +600,7 @@ public sealed class MediaScanViewModel : ViewModelBase
BlockMapList.Add((sector / _blocksToRead, double.NaN));
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void OnScanTime(ulong sector, double duration) => await Dispatcher.UIThread.InvokeAsync(() =>
{
BlockMapList.Add((sector / _blocksToRead, duration));