/// <summary>
 ///   Reparse
 /// </summary>
 /// <param name="buffer"></param>
 public static void Reparse(ITextBuffer buffer, string forFile = "")
 {
     //if (NeedReparse)
     if (VerilogGlobals.ParseStatusController.NeedReparse(forFile)) // ensure the dictionary item exists for the ParseStatus of this file and check if it is time to reparse
     {
         threadbuffer = buffer;
         threadFile   = forFile;
         threadActive = (buffer.CurrentSnapshot.Length > THREAD_TRIGGER_SIZE);
         if (threadActive)
         {
             // Do reparse work as a separate thread
             // Thread thread1 = new Thread(ThreadReparse.DoWork); // this only works if there are no paraketers to work()
             //
             // for lambda expressions on threads with parameters, see https://stackoverflow.com/questions/1195896/threadstart-with-parameters/1195915
             Thread thread1 = new Thread(() => ThreadReparse.DoWork(forFile));
             thread1.Start();
         }
         else
         {
             // Do blocking reparse work when the files are relatively small
             ThreadReparse.DoWork(forFile);
         }
     }
     // ThreadReparse.DoWork();
 }
예제 #2
0
        //public static event EventHandler LongRunningTaskEvent;

        //private static void LongRunningTaskIsDone()
        //{

        //}

        /// <summary>
        ///   Reparse
        /// </summary>
        /// <param name="buffer"></param>
        public static void Reparse(ITextBuffer buffer, string forFile = "")
        {
            //if (NeedReparse)
            if (VerilogGlobals.ParseStatusController.NeedReparse(forFile)) // ensure the dictionary item exists for the ParseStatus of this file and check if it is time to reparse
            {
                threadbuffer = buffer;
                threadFile   = forFile;

                // we'll only use threads if the CurrentSnapshot is larger than a specified size
                threadActive = (buffer.CurrentSnapshot.Length > THREAD_TRIGGER_SIZE);
                if (threadActive)
                {
                    // Do reparse work as a separate thread
                    // Thread thread1 = new Thread(ThreadReparse.DoWork); // this only works if there are no paraketers to work()
                    //
                    // for lambda expressions on threads with parameters, see https://stackoverflow.com/questions/1195896/threadstart-with-parameters/1195915
                    //LongRunningTaskEvent += LongRunningTaskIsDone;
                    System.Diagnostics.Debug.WriteLine("Reparse (threaded)...");
                    Thread thread1 = new Thread(() => {
                        ThreadReparse.DoWork(forFile);
                        // LongRunningTaskIsDone();  // this doesn't help much, as we don't have access to TagChanged from within this class
                    })
                    {
                        IsBackground = true
                    };;
                    thread1.Start();
                    System.Diagnostics.Debug.WriteLine("Reparse (thread started)...");
                }
                else
                {
                    // Do blocking reparse work when the files are relatively small
                    System.Diagnostics.Debug.WriteLine("Reparse (non-threaded)...");
                    ThreadReparse.DoWork(forFile);
                }
            }
            // ThreadReparse.DoWork();
        }