PrepareDocument() публичный Метод

Prepares the TextDocument. This method may be called by the background thread writing to the output. Once the document is prepared, it can no longer be written to.
Calling this method on the background thread ensures the TextDocument's line tokenization runs in the background and does not block the GUI.
public PrepareDocument ( ) : void
Результат void
Пример #1
0
        Task <AvalonEditTextOutput> DecompileAsync(DecompilationContext context, int outputLengthLimit)
        {
            Debug.WriteLine("Start decompilation of {0} tree nodes", context.TreeNodes.Length);

            TaskCompletionSource <AvalonEditTextOutput> tcs = new TaskCompletionSource <AvalonEditTextOutput>();

            if (context.TreeNodes.Length == 0)
            {
                // If there's nothing to be decompiled, don't bother starting up a thread.
                // (Improves perf in some cases since we don't have to wait for the thread-pool to accept our task)
                tcs.SetResult(new AvalonEditTextOutput());
                return(tcs.Task);
            }

            Thread thread = new Thread(new ThreadStart(
                                           delegate {
                try {
                    AvalonEditTextOutput textOutput = new AvalonEditTextOutput();
                    textOutput.LengthLimit          = outputLengthLimit;
                    DecompileNodes(context, textOutput);
                    textOutput.PrepareDocument();
                    tcs.SetResult(textOutput);
                } catch (OperationCanceledException) {
                    tcs.SetCanceled();
                } catch (Exception ex) {
                    tcs.SetException(ex);
                }
            }));

            thread.Start();
            return(tcs.Task);
        }