mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Convert background tasks to async void
This commit is contained in:
@@ -64,7 +64,7 @@ namespace ArchiSteamFarm {
|
|||||||
public static uint GetUnixTime() => (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
public static uint GetUnixTime() => (uint) DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void InBackground(Action action, bool longRunning = false) {
|
public static async void InBackground(Action action, bool longRunning = false) {
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
ASF.ArchiLogger.LogNullError(nameof(action));
|
ASF.ArchiLogger.LogNullError(nameof(action));
|
||||||
|
|
||||||
@@ -77,11 +77,11 @@ namespace ArchiSteamFarm {
|
|||||||
options |= TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness;
|
options |= TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.Factory.StartNew(action, CancellationToken.None, options, TaskScheduler.Default);
|
await Task.Factory.StartNew(action, CancellationToken.None, options, TaskScheduler.Default).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void InBackground<T>(Func<T> function, bool longRunning = false) {
|
public static async void InBackground<T>(Func<T> function, bool longRunning = false) {
|
||||||
if (function == null) {
|
if (function == null) {
|
||||||
ASF.ArchiLogger.LogNullError(nameof(function));
|
ASF.ArchiLogger.LogNullError(nameof(function));
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace ArchiSteamFarm {
|
|||||||
options |= TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness;
|
options |= TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.Factory.StartNew(function, CancellationToken.None, options, TaskScheduler.Default);
|
await Task.Factory.StartNew(function, CancellationToken.None, options, TaskScheduler.Default).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
|
|||||||
Reference in New Issue
Block a user