internal void ProcessPendingTextBufferChanges(ITextProvider newTextProvider, bool async) {
if (Thread.CurrentThread.ManagedThreadId != _ownerThreadId)
throw new ThreadStateException("Method should only be called on the main thread");
if (ChangesPending) {
if (async && (IsTaskRunning() || _backgroundParsingResults.Count > 0)) {
// Try next time or we may end up spawning a lot of tasks
return;
}
// Combine changes in processing with pending changes.
var changesToProcess = new TextChange(_pendingChanges, newTextProvider);
// We need to signal task start here, in the main thread since it takes
// some time before task is created and when it actually starts.
// Therefore setting task state in the task body creates a gap
// where we may end up spawning another task.
base.Run((isCancelledCallback) => ProcessTextChanges(changesToProcess, async, isCancelledCallback), async);
}
}