mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-23 17:56:49 +00:00
Misc
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ArchiSteamFarm.Localization;
|
||||
using SteamKit2;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
@@ -19,8 +19,12 @@ namespace ArchiSteamFarm {
|
||||
|
||||
private static bool ShutdownSequenceInitialized;
|
||||
|
||||
internal static async Task Exit(int exitCode = 0) {
|
||||
await InitShutdownSequence().ConfigureAwait(false);
|
||||
internal static async Task Exit(byte exitCode = 0) {
|
||||
if (exitCode != 0) {
|
||||
ASF.ArchiLogger.LogGenericError(Strings.ErrorExitingWithNonZeroErrorCode);
|
||||
}
|
||||
|
||||
await Shutdown().ConfigureAwait(false);
|
||||
Environment.Exit(exitCode);
|
||||
}
|
||||
|
||||
@@ -42,15 +46,11 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
internal static async Task Restart() {
|
||||
await InitShutdownSequence().ConfigureAwait(false);
|
||||
|
||||
try {
|
||||
Process.Start(Assembly.GetEntryAssembly().Location, string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
|
||||
} catch (Exception e) {
|
||||
ArchiLogger.LogGenericException(e);
|
||||
if (!await InitShutdownSequence().ConfigureAwait(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Environment.Exit(0);
|
||||
Application.Restart();
|
||||
}
|
||||
|
||||
private static async Task Init() {
|
||||
@@ -139,6 +139,14 @@ namespace ArchiSteamFarm {
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
|
||||
private static async Task Shutdown() {
|
||||
if (!await InitShutdownSequence().ConfigureAwait(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
|
||||
if (args?.ExceptionObject == null) {
|
||||
ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject));
|
||||
|
||||
Reference in New Issue
Block a user