mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
safer getprocesses
thanks microsoft
This commit is contained in:
parent
c386695078
commit
6e95046af2
@ -180,7 +180,7 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
if (LaunchSettings.IsMenuLaunch)
|
if (LaunchSettings.IsMenuLaunch)
|
||||||
{
|
{
|
||||||
Process? menuProcess = Process.GetProcesses().Where(x => x.MainWindowTitle == $"{ProjectName} Menu").FirstOrDefault();
|
Process? menuProcess = Utilities.GetProcessesSafe().Where(x => x.MainWindowTitle == $"{ProjectName} Menu").FirstOrDefault();
|
||||||
|
|
||||||
if (menuProcess is not null)
|
if (menuProcess is not null)
|
||||||
{
|
{
|
||||||
|
@ -415,7 +415,7 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, "Waiting for Roblox to close");
|
App.Logger.WriteLine(LOG_IDENT, "Waiting for Roblox to close");
|
||||||
|
|
||||||
while (Process.GetProcesses().Any(x => x.Id == gameClientPid))
|
while (Utilities.GetProcessesSafe().Any(x => x.Id == gameClientPid))
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Roblox has exited");
|
App.Logger.WriteLine(LOG_IDENT, $"Roblox has exited");
|
||||||
|
@ -74,5 +74,20 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
return versionInfo.ProductVersion.Replace(", ", ".");
|
return versionInfo.ProductVersion.Replace(", ", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Process[] GetProcessesSafe()
|
||||||
|
{
|
||||||
|
const string LOG_IDENT = "Utilities::GetProcessesSafe";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Process.GetProcesses();
|
||||||
|
}
|
||||||
|
catch (ArithmeticException ex) // thanks microsoft
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine(LOG_IDENT, $"Arithmetic exception occured with System.Diagnostics.Process.GetProcesses: {ex}");
|
||||||
|
return Array.Empty<Process>(); // can we retry?
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user