Start stopwatch after Steam API init

This commit is contained in:
Jaex 2021-10-26 14:15:49 +03:00
parent c75b689ee5
commit 5da2077e10

View file

@ -43,11 +43,10 @@ public static class Launcher
private static string UpdateExecutablePath = Path.Combine(UpdateFolderPath, "ShareX.exe"); private static string UpdateExecutablePath = Path.Combine(UpdateFolderPath, "ShareX.exe");
private static bool IsFirstTimeRunning, IsStartupRun, ShowInApp, IsSteamInit; private static bool IsFirstTimeRunning, IsStartupRun, ShowInApp, IsSteamInit;
private static Stopwatch SteamInitStopwatch;
public static void Run(string[] args) public static void Run(string[] args)
{ {
Stopwatch startTimer = Stopwatch.StartNew();
if (Helpers.IsCommandExist(args, "-uninstall")) if (Helpers.IsCommandExist(args, "-uninstall"))
{ {
UninstallShareX(); UninstallShareX();
@ -82,6 +81,7 @@ public static void Run(string[] args)
if (IsSteamInit) if (IsSteamInit)
{ {
SteamInitStopwatch = Stopwatch.StartNew();
break; break;
} }
@ -91,7 +91,7 @@ public static void Run(string[] args)
if (IsUpdateRequired()) if (IsUpdateRequired())
{ {
DoUpdate(); UpdateShareX();
} }
if (IsSteamInit) if (IsSteamInit)
@ -121,7 +121,12 @@ public static void Run(string[] args)
{ {
// Reason for this workaround is because Steam only allows writing review if user is played the game at least 5 minutes. // Reason for this workaround is because Steam only allows writing review if user is played the game at least 5 minutes.
// For this reason ShareX launcher will stay on for at least 10 seconds to let users eventually reach 5 minutes play time. // For this reason ShareX launcher will stay on for at least 10 seconds to let users eventually reach 5 minutes play time.
int waitTime = 10000 - (int)startTimer.ElapsedMilliseconds; int waitTime = 10000;
if (SteamInitStopwatch != null)
{
waitTime -= (int)SteamInitStopwatch.ElapsedMilliseconds;
}
if (waitTime > 0) if (waitTime > 0)
{ {
@ -188,7 +193,7 @@ private static bool IsUpdateRequired()
return false; return false;
} }
private static void DoUpdate() private static void UpdateShareX()
{ {
try try
{ {