private void LocationServiceStorageLocationChanging(object sender, PersistentStorageLocationChangingEventArgs e) { ReferenceCountedDisposable <IPersistentStorage> storage = null; lock (_lock) { if (e.SolutionId != _currentPersistentStorageSolutionId) { return; } // We will transfer ownership in a thread-safe way out so we can dispose outside the lock storage = _currentPersistentStorage; _currentPersistentStorage = null; _currentPersistentStorageSolutionId = null; } if (storage != null) { if (e.MustUseNewStorageLocationImmediately) { // Dispose storage outside of the lock. Note this only removes our reference count; clients who are still // using this will still be holding a reference count. storage.Dispose(); } else { // make it to shutdown asynchronously Task.Run(() => storage.Dispose()); } } }
private void OnWorkingFolderChanging_NoLock(PersistentStorageLocationChangingEventArgs eventArgs) { AssertIsForeground(); StorageLocationChanging?.Invoke(this, eventArgs); _currentSolutionId = eventArgs.SolutionId; _currentWorkingFolderPath = eventArgs.NewStorageLocation; }
private void OnPersistentStorageLocationServiceStorageLocationChanging(object sender, PersistentStorageLocationChangingEventArgs e) { EnqueueStorageLocationChange(e.SolutionId, e.NewStorageLocation); if (e.MustUseNewStorageLocationImmediately) { _currentRemoteWorkspaceNotificationTask.Wait(); } }