Changeset 12653 for trunk/sources/HeuristicLab.CodeEditor
- Timestamp:
- 07/07/15 15:32:42 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CodeCompletionStrategy.cs
r12646 r12653 22 22 using System; 23 23 using System.Linq; 24 using System.Threading;25 24 using System.Threading.Tasks; 26 25 using ICSharpCode.AvalonEdit.CodeCompletion; 27 26 using ICSharpCode.NRefactory.Editor; 27 using Timer = System.Timers.Timer; 28 28 29 29 namespace HeuristicLab.CodeEditor { 30 30 internal abstract class CodeCompletionStrategy : ICodeCompletionStrategy { 31 31 protected readonly CodeEditor codeEditor; 32 protected readonly T ask backgroundParser;32 protected readonly Timer parserTimer; 33 33 protected IDocument document; 34 34 … … 36 36 this.codeEditor = codeEditor; 37 37 this.codeEditor.TextEditorTextChanged += codeEditor_TextEditorTextChanged; 38 backgroundParser = new Task(DoBackgroundParsing); 38 parserTimer = new Timer(1000); 39 parserTimer.Elapsed += (sender, args) => Task.Run(() => DoParseStep()); 39 40 } 40 41 … … 45 46 46 47 public virtual void Initialize() { 47 if (backgroundParser.Status == TaskStatus.Created) 48 backgroundParser.Start(); 48 parserTimer.Enabled = true; 49 49 } 50 50 … … 93 93 } 94 94 95 protected virtual void DoBackgroundParsing() {96 while (!codeEditor.IsDisposed) {97 DoParseStep();98 Thread.Sleep(1000);99 }100 }101 102 95 private void codeEditor_TextEditorTextChanged(object sender, EventArgs e) { 103 96 var doc = codeEditor.TextEditor.Document;
Note: See TracChangeset
for help on using the changeset viewer.