Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                CleanupFileWatcher();
                if (FileChangeScheduler != null)
                {
                    FileChangeScheduler.Dispose();
                    FileChangeScheduler = null;
                }

                if (_sequentialTaskQueue != null)
                {
                    _sequentialTaskQueue.Dispose();
                    _sequentialTaskQueue = null;
                }

                if (_broadcastBlock != null)
                {
                    _broadcastBlock.Complete();
                    _broadcastBlock = null;
                }

                if (_projectRuleSubscriptionLink != null)
                {
                    _projectRuleSubscriptionLink.Dispose();
                    _projectRuleSubscriptionLink = null;
                }
            }
        }
Esempio n. 2
0
        private void WatchLaunchSettingsFile()
        {
            if (FileWatcher == null)
            {
                FileChangeScheduler?.Dispose();

                // Create our scheduler for processing file changes
                FileChangeScheduler = new TaskDelayScheduler(FileChangeProcessingDelay, _commonProjectServices.ThreadingService,
                                                             _projectServices.ProjectAsynchronousTasks.UnloadCancellationToken);

                try
                {
                    FileWatcher = new SimpleFileWatcher(Path.GetDirectoryName(_commonProjectServices.Project.FullPath),
                                                        true,
                                                        NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite,
                                                        LaunchSettingsFilename,
                                                        LaunchSettingsFile_Changed,
                                                        LaunchSettingsFile_Changed);
                }
                catch (Exception ex) when(ex is IOException || ex is ArgumentException)
                {
                    // If the project folder is no longer available this will throw, which can happen during branch switching
                }
            }
        }