Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2719


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

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

Location:
trunk/sources/HeuristicLab.CodeEditor/3.2
Files:
2 edited

Legend:

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

    r2672 r2719  
    1212    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    1313    protected override void Dispose(bool disposing) {
    14       if (InvokeRequired) {
    15         Invoke(new Action(() => this.Dispose(disposing)));
    16       } else {
    17         if (disposing) {
    18           if (components != null) {
    19             components.Dispose();
    20           }
     14      runParser = false;
     15      if (disposing) {
     16        if (components != null) {
     17          components.Dispose();
    2118        }
    22         base.Dispose(disposing);
    2319      }
     20      base.Dispose(disposing);
    2421    }
    2522
  • 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.