Code refactoring

This commit is contained in:
Jaex 2024-03-12 09:16:30 +03:00
parent c3b27567dc
commit a17a1f3047
4 changed files with 29 additions and 20 deletions

View File

@ -70,5 +70,10 @@ namespace ShareX.HelpersLib
{
WriteException(exception.ToString(), message);
}
public static void Flush()
{
Logger?.ProcessMessageQueue();
}
}
}

View File

@ -68,9 +68,6 @@ namespace ShareX.HelpersLib
else
{
RedirectArgumentsToFirstInstance(args);
DebugHelper.Logger.ProcessMessageQueue();
Environment.Exit(0);
}
}
catch (AbandonedMutexException)

View File

@ -148,6 +148,7 @@
this.Controls.Add(this.nudQRCodeSize);
this.Controls.Add(this.txtText);
this.Name = "QRCodeForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Shown += new System.EventHandler(this.QRCodeForm_Shown);
this.Resize += new System.EventHandler(this.QRCodeForm_Resize);
((System.ComponentModel.ISupportInitialize)(this.nudQRCodeSize)).EndInit();

View File

@ -298,26 +298,33 @@ namespace ShareX
MultiInstance = CLI.IsCommandExist("multi", "m");
using (SingleInstanceManager singleInstanceManager = new SingleInstanceManager(!MultiInstance, args))
using (TimerResolutionManager timerResolutionManager = new TimerResolutionManager())
{
singleInstanceManager.ArgumentsReceived += SingleInstanceManager_ArgumentsReceived;
Run();
}
if (restartRequested)
{
DebugHelper.WriteLine("ShareX restarting.");
if (restartAsAdmin)
if (singleInstanceManager.IsFirstInstance)
{
TaskHelpers.RunShareXAsAdmin("-silent");
}
else
{
Process.Start(Application.ExecutablePath);
singleInstanceManager.ArgumentsReceived += SingleInstanceManager_ArgumentsReceived;
using (TimerResolutionManager timerResolutionManager = new TimerResolutionManager())
{
Run();
}
if (restartRequested)
{
DebugHelper.WriteLine("ShareX restarting.");
if (restartAsAdmin)
{
TaskHelpers.RunShareXAsAdmin("-silent");
}
else
{
Process.Start(Application.ExecutablePath);
}
}
}
}
DebugHelper.Flush();
}
private static void Run()
@ -383,7 +390,6 @@ namespace ShareX
SettingManager.SaveAllSettings();
DebugHelper.WriteLine("ShareX closed.");
DebugHelper.Logger.ProcessMessageQueue();
}
}