IObservable <IDisposable> acquireUpdateLock() { if (updateLock != null) { return(Observable.Return(updateLock)); } return(Observable.Start(() => { var key = Utility.CalculateStreamSHA1(new MemoryStream(Encoding.UTF8.GetBytes(rootAppDirectory))); SingleGlobalInstance theLock; try { theLock = new SingleGlobalInstance(key, 2000); } catch (TimeoutException) { throw new TimeoutException("Couldn't acquire update lock, another instance may be running updates"); } var ret = Disposable.Create(() => { theLock.Dispose(); updateLock = null; }); updateLock = ret; return ret; })); }
public IDisposable AcquireUpdateLock() { var key = Utility.CalculateStreamSHA1(new MemoryStream(Encoding.UTF8.GetBytes(rootAppDirectory))); var ret = new SingleGlobalInstance(key, 500); hasUpdateLock = true; return(Disposable.Create(() => { ret.Dispose(); hasUpdateLock = false; })); }
public void Dispose() { mutex.Dispose(); context?.Dispose(); _hidGuardianClient?.Dispose(); }
IObservable<IDisposable> acquireUpdateLock() { if (updateLock != null) return Observable.Return(updateLock); return Observable.Start(() => { var key = Utility.CalculateStreamSHA1(new MemoryStream(Encoding.UTF8.GetBytes(rootAppDirectory))); SingleGlobalInstance theLock; try { theLock = new SingleGlobalInstance(key, 2000); } catch (TimeoutException) { throw new TimeoutException("Couldn't acquire update lock, another instance may be running updates"); } var ret = Disposable.Create(() => { theLock.Dispose(); updateLock = null; }); updateLock = ret; return ret; }); }