Beispiel #1
0
        private void CreateParseRequest(string file, string text, ModuleId id)
        {
            LibraryTask task = new LibraryTask(file, text);

            task.ModuleID = id;
            lock (requests)
            {
                requests.Enqueue(task);
            }
            requestPresent.Set();
        }
Beispiel #2
0
        /// <summary>
        /// Main function of the parsing thread.
        /// This function waits on the queue of the parsing requests and build the parsing tree for
        /// a specific file. The resulting tree is built using LibraryNode objects so that it can
        /// be used inside the class view or object browser.
        /// </summary>
        private void ParseThread()
        {
            const int waitTimeout = 500;

            // Define the array of events this function is interest in.
            WaitHandle[] eventsToWait = new WaitHandle[] { requestPresent, shutDownStarted };
            // Execute the tasks.
            while (true)
            {
                // Wait for a task or a shutdown request.
                int waitResult = WaitHandle.WaitAny(eventsToWait, waitTimeout, false);
                if (1 == waitResult)
                {
                    // The shutdown of this component is started, so exit the thread.
                    return;
                }
                LibraryTask task = null;
                lock (requests)
                {
                    if (0 != requests.Count)
                    {
                        task = requests.Dequeue();
                    }
                    if (0 == requests.Count)
                    {
                        requestPresent.Reset();
                    }
                }

                if (null == task)
                {
                    continue;
                }

                // parse the file to search for classes and functions
                LibraryNode fileNode = parser.Parse(task);

                if (null != task.ModuleID)
                {
                    UpdateClassView(fileNode);
                    //SQLanguageService ls = (SQLanguageService)provider.GetService(typeof(SQLanguageService));
                    //ls.SynchronizeDropdowns();
                }
            }
        }