Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/29/10 14:33:03 (15 years ago)
Author:
epitzer
Message:

try a different method for signaling the parser thread to terminate (#842)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CodeEditor/3.2/CodeEditor.cs

    r2673 r2719  
    306306    }
    307307
     308    private bool runParser = true;
    308309    private void ParserThread() {
    309310      BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Loading mscorlib..."; }));
     
    311312      ParseStep();
    312313      BeginInvoke(new MethodInvoker(delegate { parserThreadLabel.Text = "Ready"; }));
     314      while (runParser && !IsDisposed) {
     315        ParseStep();
     316        Thread.Sleep(2000);
     317      }
     318    }
     319
     320    private void ParseStep() {
    313321      try {
    314         while (!IsDisposed) {
    315           ParseStep();
    316           Thread.Sleep(2000);
    317         }
     322        string code = null;
     323        Invoke(new MethodInvoker(delegate { code = textEditor.Text; }));
     324        TextReader textReader = new StringReader(code);
     325        Dom.ICompilationUnit newCompilationUnit;
     326        NRefactory.SupportedLanguage supportedLanguage;
     327        supportedLanguage = NRefactory.SupportedLanguage.CSharp;
     328        using (NRefactory.IParser p = NRefactory.ParserFactory.CreateParser(supportedLanguage, textReader)) {
     329          p.ParseMethodBodies = false;
     330          p.Parse();
     331          newCompilationUnit = ConvertCompilationUnit(p.CompilationUnit);
     332        }
     333        projectContent.UpdateCompilationUnit(lastCompilationUnit, newCompilationUnit, DummyFileName);
     334        lastCompilationUnit = newCompilationUnit;
     335        parseInformation.SetCompilationUnit(newCompilationUnit);
    318336      } catch { }
    319     }
    320 
    321     private void ParseStep() {
    322       string code = null;
    323       Invoke(new MethodInvoker(delegate {
    324         code = textEditor.Text;
    325       }));
    326       TextReader textReader = new StringReader(code);
    327       Dom.ICompilationUnit newCompilationUnit;
    328       NRefactory.SupportedLanguage supportedLanguage;
    329       supportedLanguage = NRefactory.SupportedLanguage.CSharp;
    330       using (NRefactory.IParser p = NRefactory.ParserFactory.CreateParser(supportedLanguage, textReader)) {
    331         p.ParseMethodBodies = false;
    332         p.Parse();
    333         newCompilationUnit = ConvertCompilationUnit(p.CompilationUnit);
    334       }
    335       projectContent.UpdateCompilationUnit(lastCompilationUnit, newCompilationUnit, DummyFileName);
    336       lastCompilationUnit = newCompilationUnit;
    337       parseInformation.SetCompilationUnit(newCompilationUnit);
    338337    }
    339338
Note: See TracChangeset for help on using the changeset viewer.