Ejemplo n.º 1
0
            public static BackgroundParserTask CreateAndStart(RazorEditorParser parser, TextChange change, Block parseTree)
            {
                CancellationTokenSource cancelSource = new CancellationTokenSource();
                BackgroundParserTask    task         = new BackgroundParserTask()
                {
                    CancelSource = cancelSource
                };
                CancellationToken token = cancelSource.Token;

                task.Task = Task.Factory.StartNew(() => {
                    try {
                        Interlocked.Increment(ref _activeTaskCount);
                        parser.ProcessChange(token, change, parseTree);
                    }
                    catch (OperationCanceledException) {
                    }
#if DEBUG
                    catch (Exception ex) {
                        if (Debugger.IsAttached)
                        {
                            throw;
                        }
                        Debug.Fail("Unexpected exception thrown by parser task", ex.ToString());
                    }
#else
                    catch (Exception) {
                    }
#endif
                }, token);
                return(task);
            }
Ejemplo n.º 2
0
 protected internal virtual void QueueFullReparse(TextChange change)
 {
     if (_currentTask != null)
     {
         _currentTask.Dispose();
     }
     _currentTask = BackgroundParserTask.CreateAndStart(this, change, _currentParseTree);
 }
Ejemplo n.º 3
0
            public static BackgroundParserTask CreateAndStart(RazorEditorParser parser, TextChange change, Block parseTree) {
                CancellationTokenSource cancelSource = new CancellationTokenSource();
                BackgroundParserTask task = new BackgroundParserTask() {
                    CancelSource = cancelSource
                };
                CancellationToken token = cancelSource.Token;

                task.Task = Task.Factory.StartNew(() => {
                    try {
                        Interlocked.Increment(ref _activeTaskCount);
                        parser.ProcessChange(token, change, parseTree);
                    }
                    catch (OperationCanceledException) {
                    }
#if DEBUG
                    catch (Exception ex) {
                        if (Debugger.IsAttached) {
                            throw;
                        }
                        Debug.Fail("Unexpected exception thrown by parser task", ex.ToString());
                    }
#else
                    catch (Exception) {

                    }
#endif
                }, token);
                return task;
            }
Ejemplo n.º 4
0
 protected internal virtual void QueueFullReparse(TextChange change) {
     if (_currentTask != null) {
         _currentTask.Dispose();
     }
     _currentTask = BackgroundParserTask.CreateAndStart(this, change, _currentParseTree);
 }