Include dates in console messages
This commit is contained in:
parent
b366db9cae
commit
f1373fcbfa
@ -23,53 +23,65 @@ internal sealed class Program
|
||||
e.Cancel = true;
|
||||
};
|
||||
|
||||
while (!cts.IsCancellationRequested)
|
||||
try
|
||||
{
|
||||
var launchers = Process.GetProcessesByName("XIVLauncher").Where(x => !x.HasExited).ToArray();
|
||||
if (launchers.Length >= 2)
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
Console.WriteLine("Found multiple launcher instances??");
|
||||
KillAll(launchers);
|
||||
continue;
|
||||
}
|
||||
else if (launchers.Length == 1)
|
||||
{
|
||||
Console.WriteLine($"Waiting for launcher {launchers.Single().Id} to finish");
|
||||
await launchers.Single().WaitForExitAsync(cts.Token).ConfigureAwait(false);
|
||||
await Task.Delay(1000, cts.Token).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
var launchers = Process.GetProcessesByName("XIVLauncher").Where(x => !x.HasExited).ToArray();
|
||||
if (launchers.Length >= 2)
|
||||
{
|
||||
Console.WriteLine($"[{DateTime.Now}] Found multiple launcher instances??");
|
||||
KillAll(launchers);
|
||||
continue;
|
||||
}
|
||||
else if (launchers.Length == 1)
|
||||
{
|
||||
Console.WriteLine($"[{DateTime.Now}] Waiting for launcher {launchers.Single().Id} to finish");
|
||||
await launchers.Single().WaitForExitAsync(cts.Token).ConfigureAwait(false);
|
||||
await Task.Delay(1000, cts.Token).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
var ffxiv = Process.GetProcessesByName("ffxiv_dx11").Where(x => !x.HasExited).ToArray();
|
||||
if (ffxiv.Length >= 2)
|
||||
{
|
||||
Console.WriteLine("Found multiple XIV instances??");
|
||||
KillAll(ffxiv);
|
||||
continue;
|
||||
}
|
||||
else if (ffxiv.Length == 1)
|
||||
{
|
||||
Console.WriteLine($"Waiting for FFXIV {ffxiv.Single().Id} to finish");
|
||||
await ffxiv.Single().WaitForExitAsync(cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var process = Process.Start(new ProcessStartInfo
|
||||
var ffxiv = Process.GetProcessesByName("ffxiv_dx11").Where(x => !x.HasExited).ToArray();
|
||||
if (ffxiv.Length >= 2)
|
||||
{
|
||||
FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
@"XIVLauncher\XIVLauncher.exe"),
|
||||
UseShellExecute = false,
|
||||
});
|
||||
if (process != null)
|
||||
Console.WriteLine($"[{DateTime.Now}] Found multiple XIV instances??");
|
||||
KillAll(ffxiv);
|
||||
continue;
|
||||
}
|
||||
else if (ffxiv.Length == 1)
|
||||
{
|
||||
await process.WaitForExitAsync(cts.Token).ConfigureAwait(false);
|
||||
Console.WriteLine("Started launcher...");
|
||||
Console.WriteLine($"[{DateTime.Now}] Waiting for FFXIV {ffxiv.Single().Id} to finish");
|
||||
await ffxiv.Single().WaitForExitAsync(cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
Console.WriteLine("No process started?");
|
||||
}
|
||||
{
|
||||
var process = Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
@"XIVLauncher\XIVLauncher.exe"),
|
||||
UseShellExecute = false,
|
||||
});
|
||||
if (process != null)
|
||||
{
|
||||
await process.WaitForExitAsync(cts.Token).ConfigureAwait(false);
|
||||
Console.WriteLine($"[{DateTime.Now}] Started launcher...");
|
||||
}
|
||||
else
|
||||
Console.WriteLine($"[{DateTime.Now}] No process started?");
|
||||
}
|
||||
|
||||
await Task.Delay(1000, cts.Token).ConfigureAwait(false);
|
||||
await Task.Delay(1000, cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
// expected if we press ctrl-c
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"[{DateTime.Now}] Unexpected exception: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user