# Performance

> Keep WPF windows responsive with TX Text Control: the dispatcher, ServerTextControl on background threads, large documents, memory, conversion and mail merge.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Performance
- **799 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/llms-full.txt

---

A WPF window freezes whenever its dispatcher is busy, and loading, converting and merging documents can keep it busy for seconds or minutes. Developers who build editors, report generators or batch tools with TX Text Control .NET for WPF find here how its classes fit the threading model of WPF, how to move long work to other threads and processes, how to handle large documents and memory, and which of Text Control's measurements back each recommendation.

### The Editor and the Engine Without a Window

Two classes hold documents, and they belong to different threads:

|  | WPF `TextControl` | `ServerTextControl` |
|---|---|---|
| Used for | The document the user sees and edits | Documents your code creates, converts, merges or prints |
| Thread | The UI thread of its window, reached through its `Dispatcher` | Any thread, one instance per thread |
| Undo buffer and screen rendering | Yes | No |
| Disposal | Not disposable; it lives as long as its window | Disposed by your code, in a `using` block |

`Load`, `Save` and the merge methods of `MailMerge` are synchronous and occupy the thread that calls them. Work that takes longer than a moment therefore runs in a `ServerTextControl` on a thread of the thread pool, and only the result goes back to the editor. TX Text Control is thread safe, but its threads can wait for each other, which is why Text Control recommends separate processes for very large batches.

### Find the Right Page

| If you want to | Read |
|---|---|
| Understand which objects belong to the UI thread and get results back to the editor | [Dispatcher and UI Thread Access](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/dispatcher/llms-full.txt) |
| Convert or process many files on other threads, with progress and a cancel button | [Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/background-operations/llms-full.txt) |
| Build and process documents with hundreds of pages | [Large Documents](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/large-documents/llms-full.txt) |
| Dispose instances, find leaks and stay below the handle limits of Windows | [Memory Usage and Resource Disposal](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/memory-usage/llms-full.txt) |
| Choose the format documents are kept in and load only what a task needs | [Document Loading and Conversion](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/loading-conversion/llms-full.txt) |
| Know what a merge costs, merge in the background and in separate processes | [Mail Merge Performance](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/mail-merge/llms-full.txt) |
| See every measure at a glance and measure your own documents | [Performance Best Practices](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/best-practices/llms-full.txt) |

### Recommended Order

1. [Dispatcher and UI Thread Access](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/dispatcher/llms-full.txt): the rules every other page builds on.
2. [Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/background-operations/llms-full.txt): the pattern for any work that takes longer than a moment.
3. [Performance Best Practices](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/best-practices/llms-full.txt): the remaining measures, each linked to its page.

The measurements quoted in this section are Text Control's own, and most of them were taken with TX Text Control .NET Server. Each is given with the conditions it was measured under; your documents and computers decide the actual numbers.

### Related Pages

- [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-processing/servertextcontrol/llms-full.txt): the lifecycle of `ServerTextControl` in a WPF application.
- [Dispatcher and Thread Access](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/dispatcher/llms-full.txt): problems with frozen windows and unhandled exceptions.
- [Mail Merge and Reporting](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/llms-full.txt): templates, data sources and merge settings.

---

## In This Section

- [Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/background-operations/llms-full.txt): Convert many files on background threads in WPF with ServerTextControl and Parallel.ForEach, with Progress, a cancel button and the limits of threads.
- [Performance Best Practices](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/best-practices/llms-full.txt): All performance measures for WPF apps with TX Text Control and their effect, DefaultFormattingPrinter in App.xaml.cs and a background Stopwatch test of a merge.
- [Dispatcher and UI Thread Access](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/dispatcher/llms-full.txt): Which TX Text Control objects belong to the WPF UI thread, how documents cross threads as byte arrays, and CheckAccess and InvokeAsync for the TextControl.
- [Large Documents](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/large-documents/llms-full.txt): Build long documents for the WPF TextControl in one undo step with Selection objects and ServerTextControl, replace text in large DOCX files, shrink PDFs.
- [Document Loading and Conversion](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/loading-conversion/llms-full.txt): Speed up loading and conversion in WPF: the TX Text Control format for drafts, quick previews with LoadImages and first-page PDF import, one instance per batch.
- [Mail Merge Performance](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/mail-merge/llms-full.txt): What MailMerge costs per invoice and merge block, templates that merge faster, WPF merges in the background with progress and cancel, multi-process batches.
- [Memory Usage and Resource Disposal](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/memory-usage/llms-full.txt): Find undisposed ServerTextControl instances in WPF apps, watch USER and GDI handles, see why the WPF TextControl needs no Dispose, and handle OutOfMemory.

---

## Nearby

- **Previous:** [Secure Application Deployment](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/security/deployment/llms-full.txt)
- **Next:** [Dispatcher and UI Thread Access](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/performance/dispatcher/llms-full.txt)
