public static void Init() { if (init) { return; } init = true; worker = new WorkerThread(); thread = new Thread( delegate() { LoggingService.Info("start background compiler"); worker.RunLoop(); } ); thread.IsBackground = true; thread.Name = "CSBackgroundCompiler"; ParserService.ParserUpdateStepFinished += delegate { if (WorkbenchSingleton.Workbench.ActiveViewContent == null) { return; } if (ParserService.LoadSolutionProjectsThreadRunning) { return; } ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider; if (provider == null) { return; } ParseInformation parseInfo = ParserService.GetExistingParseInformation(provider.TextEditor.FileName); if (parseInfo == null) { return; } string fileName = provider.TextEditor.FileName; string fileContent = provider.TextEditor.Document.Text; IProjectContent pc = parseInfo.CompilationUnit.ProjectContent; if (currentWork == null) { thread.Start(); } if (currentWork == null || currentWork.IsCompleted) { currentWork = worker.Enqueue(() => RunCompile(fileName, fileContent, pc)); } }; }