# Performance

> Keep Windows Forms apps responsive with TX Text Control: TextControl on the UI thread, ServerTextControl in the background, memory, large files and mail merge.

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

---

Users judge a Windows Forms application by whether its form responds, and TX Text Control applications are no exception: the form should stay usable while a report is merged, a folder is converted or a long contract is opened. Read on for how to keep document work away from the UI thread, handle large documents and many files, release what TX Text Control holds, and what Text Control's own measurements say about each of these.

### Two Classes, Two Kinds of Work

The work of a TX Text Control application falls into two kinds, and each has its own class:

|  | `TextControl` | `ServerTextControl` |
|---|---|---|
| Used for | The document the user sees and edits | Documents your code creates, converts, merges or prints |
| Thread | The UI thread of the form | Any thread, one instance per thread |
| Undo buffer and screen rendering | Yes | No |
| Released when | The form is closed | Your code disposes it |

`Load`, `Save` and the merge methods of `MailMerge` are synchronous, so the thread that calls them is busy until they return. Everything that takes longer than a moment belongs in a `ServerTextControl` on a background thread. TX Text Control is thread safe, but threads can wait for each other inside it, and for large batches Text Control recommends several processes instead of several threads.

### Find the Right Page

| If you want to | Read |
|---|---|
| Keep the form responsive, report progress, cancel work and update the editor from other threads | [UI Threading and Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/threading/llms-full.txt) |
| Build, insert and process documents with hundreds of pages | [Large Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/large-documents/llms-full.txt) |
| Dispose instances, find those that are left behind and understand the handle limit of Windows | [Memory Usage and Resource Disposal](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/memory-usage/llms-full.txt) |
| Load and convert many documents, and choose the format to keep them in | [Document Loading and Conversion](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/loading-conversion/llms-full.txt) |
| Know what a merge costs, merge in the background and merge large batches in processes | [Mail Merge Performance](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/mail-merge/llms-full.txt) |
| See all measures at a glance, set a default formatting printer and measure your own workload | [Performance Best Practices](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/best-practices/llms-full.txt) |

### Where to Start

1. [Performance Best Practices](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/best-practices/llms-full.txt) lists every measure with its effect and links the page that shows the code.
2. [UI Threading and Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/threading/llms-full.txt) gives the rules that every background task in a Windows Forms application follows.
3. [Memory Usage and Resource Disposal](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/memory-usage/llms-full.txt) before your application runs for hours or days.

The numbers on these pages come from benchmarks that Text Control has published, most of them measured with TX Text Control .NET Server. Each one is given with its conditions, and none replaces a measurement with your own documents.

### Related Pages

- [Using ServerTextControl in Desktop Applications](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/servertextcontrol/llms-full.txt): create, use and dispose `ServerTextControl` in a form.
- [Exceptions and Error Handling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/exceptions/llms-full.txt): catch errors of background work.
- [Mail Merge and Reporting](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/llms-full.txt): templates, data sources and merge settings.

---

## In This Section

- [Performance Best Practices](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/best-practices/llms-full.txt): Every performance measure for Windows Forms apps with its measured effect, plus DefaultFormattingPrinter in Program.cs and a Stopwatch test of a merge.
- [Large Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/large-documents/llms-full.txt): Handle long documents in Windows Forms: 64-bit builds, Selection objects and Selection.Load in one undo step, text replacement in large DOCX files, PDF size.
- [Document Loading and Conversion](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/loading-conversion/llms-full.txt): Load and convert documents faster in Windows Forms: keep the TX Text Control format, reuse one ServerTextControl, LoadImages and PDFImportSettings, PDF last.
- [Mail Merge Performance](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/mail-merge/llms-full.txt): Measured MailMerge times, faster merge block design, background merges in Windows Forms with DataRowMerged progress and Cancel, and processes for large batches.
- [Memory Usage and Resource Disposal](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/memory-usage/llms-full.txt): Dispose ServerTextControl and MailMerge, count live instances and USER and GDI handles, switch off AllowUndo and handle OutOfMemory errors in Windows Forms.
- [UI Threading and Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/threading/llms-full.txt): Run TX Text Control work off the Windows Forms UI thread: ServerTextControl in Task.Run, InvokeRequired, BeginInvoke, progress, cancel and parallel loops.

---

## Nearby

- **Previous:** [Secure Application Deployment](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/security/deployment/llms-full.txt)
- **Next:** [UI Threading and Background Operations](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/threading/llms-full.txt)
