From 2972827f496202a6355b9be0437e323bd739aa4e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 12 Oct 2022 08:36:24 -0500 Subject: fix warnings --- src/slskd/Program.cs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 56ab6317..8b816f48 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -32,8 +32,6 @@ namespace slskd using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; - using System.Threading; - using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; @@ -262,29 +260,36 @@ namespace slskd return; } + var reqInitialOwnership = false; - using(var mutex = new Mutex(reqInitialOwnership, AppName)) + + using (var mutex = new Mutex(reqInitialOwnership, AppName)) { var hasHandle = false; - try{ - try{ - if(!mutex.WaitOne(0, false)){ - Console.WriteLine("Another instance of this program is running"); - Environment.Exit(0); - } + try + { + try + { + if (!mutex.WaitOne(0, false)) + { + Console.WriteLine("Another instance of this program is running"); + Environment.Exit(0); + } } catch (AbandonedMutexException) { - hasHandle=true; + hasHandle = true; } } finally { - if(hasHandle) + if (hasHandle) + { mutex.ReleaseMutex(); + } } - } - + } + if (GenerateCertificate) { GenerateX509Certificate(password: Cryptography.Random.GetBytes(16).ToBase62String(), filename: $"{AppName}.pfx"); -- cgit v1.2.3