示例#1
0
        /// <summary>
        /// Loops through all files that have been changed since the last flush, allowing
        /// Glue (and plugins) to react to these changed files.
        /// </summary>
        /// <remarks>
        /// The handling of the system event is in ChangedFileGroup.
        /// </remarks>
        public static void Flush()
        {
            lock (FileWatchManager.LockObject)
            {
                if (!IsFlushing && PerformFlushing && !MainGlueWindow.GetIsTortoiseRunning())
                {
                    IsFlushing = true;

                    List <string> filesToFlush = new List <string>();


                    if (mChangedProjectFiles.CanFlush)
                    {
                        filesToFlush.AddRange(mChangedProjectFiles.AllFiles);
                        mChangedProjectFiles.Clear();
                    }

                    bool anyFlushed = false;

                    foreach (string file in filesToFlush.Distinct())
                    {
                        anyFlushed = true;

                        var fileCopy = file;

                        // The task internally will skip files if they are to be ignored, but projects can have
                        // *so many* generated files, that putting a check here on generated can eliminate hundreds
                        // of tasks from being created, improving startup performance
                        IgnoreReason reason;
                        bool         isIgnored = IsFileIgnored(file, out reason);

                        // November 12, 2019
                        // Vic asks - why do we only ignore files that are generated here?
                        //var skip = isIgnored && reason == IgnoreReason.GeneratedCodeFile;
                        var skip = isIgnored;

                        if (!skip)
                        {
                            TaskManager.Self.AddSync(() =>
                            {
                                if (ReactToChangedFile(file))
                                {
                                    UnreferencedFilesManager.Self.IsRefreshRequested = true;
                                }
                            },
                                                     "Reacting to changed file " + file);
                        }
                    }

                    if (anyFlushed)
                    {
                        UnreferencedFilesManager.Self.RefreshUnreferencedFiles(async: true);
                    }
                    IsFlushing = false;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Loops through all files that have been changed since the last flush, allowing
        /// Glue (and plugins) to react to these changed files.
        /// </summary>
        /// <remarks>
        /// The handling of the system event is in ChangedFileGroup.
        /// </remarks>
        public static void Flush()
        {
            lock (FileWatchManager.LockObject)
            {
                if (!IsFlushing && PerformFlushing && !MainGlueWindow.GetIsTortoiseRunning())
                {
                    IsFlushing = true;

                    List <string> filesToFlush = new List <string>();


                    if (mChangedProjectFiles.CanFlush)
                    {
                        filesToFlush.AddRange(mChangedProjectFiles.AllFiles);
                        mChangedProjectFiles.Clear();;
                    }

                    bool anyFlushed = false;

                    foreach (string file in filesToFlush.Distinct())
                    {
                        anyFlushed = true;

                        var fileCopy = file;
                        TaskManager.Self.AddSync(() =>
                        {
                            if (ReactToChangedFile(file))
                            {
                                UnreferencedFilesManager.Self.IsRefreshRequested = true;
                            }
                        },
                                                 "Reacting to changed file " + file);
                    }

                    if (anyFlushed)
                    {
                        TaskManager.Self.AddSync(() =>
                        {
                            if (UnreferencedFilesManager.Self.IsRefreshRequested)
                            {
                                // do this first in case someone else requests a refresh while the refresh is going

                                UnreferencedFilesManager.Self.IsRefreshRequested = false;

                                UnreferencedFilesManager.Self.RefreshUnreferencedFiles(async: false);
                            }
                        },
                                                 "Refreshing unreferenced files");
                    }
                    IsFlushing = false;
                }
            }
        }