public SingleInstance(string name, bool ignoreCase = true) { NameOfMutant = $"SingleInstance_" + name._NonNullTrim(); if (ignoreCase) { NameOfMutant = NameOfMutant.ToLowerInvariant(); } lock (LockObj) { if (ProcessWideSingleInstanceHashSet.Contains(NameOfMutant)) { throw new ApplicationException($"The single instance is already existing with this process."); } MutantBase mb = MutantBase.Create(NameOfMutant, true); try { mb.Lock(true); Mutant = mb; } catch { mb._DisposeSafe(); throw; } ProcessWideSingleInstanceHashSet.Add(NameOfMutant); } }
public MutantWin32Impl(string name) { InternalName = @"Global\" + MutantBase.GenerateInternalName(name); MutexObj = new Mutex(false, InternalName, out _); }
public MutantWin32ForSingleInstanceImpl(string name) { InternalName = @"Global\si_" + MutantBase.GenerateInternalName(name); }
public MutantUnixImpl(string name) { Filename = Path.Combine(Env.UnixMutantDir, MutantBase.GenerateInternalName(name) + Extension); IO.MakeDirIfNotExists(Env.UnixMutantDir); }