Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/15 15:32:42 (9 years ago)
Author:
jkarder
Message:

#2419: refactored CodeCompletionStrategy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CodeCompletionStrategy.cs

    r12646 r12653  
    2222using System;
    2323using System.Linq;
    24 using System.Threading;
    2524using System.Threading.Tasks;
    2625using ICSharpCode.AvalonEdit.CodeCompletion;
    2726using ICSharpCode.NRefactory.Editor;
     27using Timer = System.Timers.Timer;
    2828
    2929namespace HeuristicLab.CodeEditor {
    3030  internal abstract class CodeCompletionStrategy : ICodeCompletionStrategy {
    3131    protected readonly CodeEditor codeEditor;
    32     protected readonly Task backgroundParser;
     32    protected readonly Timer parserTimer;
    3333    protected IDocument document;
    3434
     
    3636      this.codeEditor = codeEditor;
    3737      this.codeEditor.TextEditorTextChanged += codeEditor_TextEditorTextChanged;
    38       backgroundParser = new Task(DoBackgroundParsing);
     38      parserTimer = new Timer(1000);
     39      parserTimer.Elapsed += (sender, args) => Task.Run(() => DoParseStep());
    3940    }
    4041
     
    4546
    4647    public virtual void Initialize() {
    47       if (backgroundParser.Status == TaskStatus.Created)
    48         backgroundParser.Start();
     48      parserTimer.Enabled = true;
    4949    }
    5050
     
    9393    }
    9494
    95     protected virtual void DoBackgroundParsing() {
    96       while (!codeEditor.IsDisposed) {
    97         DoParseStep();
    98         Thread.Sleep(1000);
    99       }
    100     }
    101 
    10295    private void codeEditor_TextEditorTextChanged(object sender, EventArgs e) {
    10396      var doc = codeEditor.TextEditor.Document;
Note: See TracChangeset for help on using the changeset viewer.