예제 #1
0
        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;
            }));
        }
예제 #2
0
        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;
            }));
        }
예제 #3
0
파일: App.xaml.cs 프로젝트: poutine70/UCR
 public void Dispose()
 {
     mutex.Dispose();
     context?.Dispose();
     _hidGuardianClient?.Dispose();
 }
예제 #4
0
        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;
            });
        }