()
| 263 | } |
| 264 | |
| 265 | Task<IDisposable> acquireUpdateLock() |
| 266 | { |
| 267 | if (updateLock != null) return Task.FromResult(updateLock); |
| 268 | |
| 269 | return Task.Run(() => { |
| 270 | var key = Utility.CalculateStreamSHA1(new MemoryStream(Encoding.UTF8.GetBytes(rootAppDirectory))); |
| 271 | |
| 272 | IDisposable theLock; |
| 273 | try { |
| 274 | theLock = ModeDetector.InUnitTestRunner() ? |
| 275 | Disposable.Create(() => {}) : new SingleGlobalInstance(key, TimeSpan.FromMilliseconds(2000)); |
| 276 | } catch (TimeoutException) { |
| 277 | throw new TimeoutException("Couldn't acquire update lock, another instance may be running updates"); |
| 278 | } |
| 279 | |
| 280 | var ret = Disposable.Create(() => { |
| 281 | theLock.Dispose(); |
| 282 | updateLock = null; |
| 283 | }); |
| 284 | |
| 285 | updateLock = ret; |
| 286 | return ret; |
| 287 | }); |
| 288 | } |
| 289 | |
| 290 | /// <summary> |
| 291 | /// Calculates the total percentage of a specific step that should report within a specific range. |
nothing calls this directly
no test coverage detected