diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 591909c..0302340 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -119,6 +119,8 @@ namespace Bloxstrap App.Logger.WriteLine(LOG_IDENT, "Performing connectivity check..."); + SetStatus("Connecting to Roblox..."); + try { await RobloxDeployment.GetInfo(RobloxDeployment.DefaultChannel); @@ -158,8 +160,9 @@ namespace Bloxstrap try { - Mutex.OpenExisting("Bloxstrap_BootstrapperMutex").Close(); - App.Logger.WriteLine(LOG_IDENT, "Bloxstrap_BootstrapperMutex mutex exists, waiting..."); + Mutex.OpenExisting("Bloxstrap_SingletonMutex").Close(); + App.Logger.WriteLine(LOG_IDENT, "Bloxstrap_SingletonMutex mutex exists, waiting..."); + SetStatus("Waiting for other instances..."); mutexExists = true; } catch (Exception) @@ -168,7 +171,7 @@ namespace Bloxstrap } // wait for mutex to be released if it's not yet - await using AsyncMutex mutex = new("Bloxstrap_BootstrapperMutex"); + await using var mutex = new AsyncMutex(true, "Bloxstrap_SingletonMutex"); await mutex.AcquireAsync(_cancelTokenSource.Token); // reload our configs since they've likely changed by now @@ -219,8 +222,6 @@ namespace Bloxstrap { const string LOG_IDENT = "Bootstrapper::CheckLatestVersion"; - SetStatus("Connecting to Roblox..."); - ClientVersion clientVersion; try diff --git a/Bloxstrap/Utility/AsyncMutex.cs b/Bloxstrap/Utility/AsyncMutex.cs index 400ccc8..0cbf2f7 100644 --- a/Bloxstrap/Utility/AsyncMutex.cs +++ b/Bloxstrap/Utility/AsyncMutex.cs @@ -4,13 +4,15 @@ public sealed class AsyncMutex : IAsyncDisposable { + private readonly bool _initiallyOwned; private readonly string _name; private Task? _mutexTask; private ManualResetEventSlim? _releaseEvent; private CancellationTokenSource? _cancellationTokenSource; - public AsyncMutex(string name) + public AsyncMutex(bool initiallyOwned, string name) { + _initiallyOwned = initiallyOwned; _name = name; } @@ -31,7 +33,7 @@ try { CancellationToken cancellationToken = _cancellationTokenSource.Token; - using var mutex = new Mutex(false, _name); + using var mutex = new Mutex(_initiallyOwned, _name); try { // Wait for either the mutex to be acquired, or cancellation