Ejemplo 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;
                }
            }
        }
Ejemplo 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
                }
            }
        }
        /// <summary>
        /// Handler for when the Launch settings file changes. Actually, we watch the project root so any
        /// file with the name LaunchSettings.json. We don't need to special case because, if a file with this name
        /// changes we will only check if the one we cared about was modified.
        /// </summary>
        protected void LaunchSettingsFile_Changed(object sender, FileSystemEventArgs e)
        {
            if (!IgnoreFileChanges)
            {
#pragma warning disable CS0618  // We're in a synchronous callback
                string fileName = LaunchSettingsFile;
#pragma warning restore CS0618

                // Only do something if the file is truly different than what we synced. Here, we want to
                // throttle.
                if (!FileManager.FileExists(fileName) || FileManager.LastFileWriteTime(fileName) != LastSettingsFileSyncTime)
                {
                    FileChangeScheduler.ScheduleAsyncTask(async token =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            return;
                        }

                        // Updates need to be sequenced
                        await _sequentialTaskQueue.ExecuteTask(async() =>
                        {
                            await UpdateProfilesAsync(null).ConfigureAwait(false);
                        }).ConfigureAwait(false);
                    });
                }
            }
        }
Ejemplo n.º 4
0
        protected Task HandleLaunchSettingsFileChangedAsync()
        {
            if (!IgnoreFileChanges)
            {
#pragma warning disable CS0618  // We're in a synchronous callback
                string fileName = LaunchSettingsFile;
#pragma warning restore CS0618

                // Only do something if the file is truly different than what we synced. Here, we want to
                // throttle.
                if (!_fileSystem.FileExists(fileName) || _fileSystem.LastFileWriteTime(fileName) != LastSettingsFileSyncTime)
                {
                    return(FileChangeScheduler.ScheduleAsyncTask(token =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            return Task.CompletedTask;
                        }

                        // Updates need to be sequenced
                        return _sequentialTaskQueue.ExecuteTask(() => UpdateProfilesAsync(null));
                    }).Task);
                }
            }

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Handler for when the Launch settings file changes. Actually, we watch the project root so any
        /// file with the name LaunchSettings.json. We don't need to special case because, if a file with this name
        /// changes we will only check if the one we cared about was modified.
        /// </summary>
        protected void LaunchSettingsFile_Changed(object sender, FileSystemEventArgs e)
        {
            if (!IgnoreFileChanges)
            {
                // Only do something if the file is truly different than what we synced. Here, we want to
                // throttle.
                if (!FileManager.FileExists(LaunchSettingsFile) || FileManager.LastFileWriteTime(LaunchSettingsFile) != LastSettingsFileSyncTime)
                {
                    FileChangeScheduler.ScheduleAsyncTask(async token => {
                        if (token.IsCancellationRequested)
                        {
                            return;
                        }

                        await UpdateProfilesAsync(null).ConfigureAwait(false);
                    });
                }
            }
        }