Performance
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 |
| Build, insert and process documents with hundreds of pages | Large Documents |
| Dispose instances, find those that are left behind and understand the handle limit of Windows | Memory Usage and Resource Disposal |
| Load and convert many documents, and choose the format to keep them in | Document Loading and Conversion |
| Know what a merge costs, merge in the background and merge large batches in processes | Mail Merge Performance |
| See all measures at a glance, set a default formatting printer and measure your own workload | Performance Best Practices |
Where to Start
- Performance Best Practices lists every measure with its effect and links the page that shows the code.
- UI Threading and Background Operations gives the rules that every background task in a Windows Forms application follows.
- Memory Usage and Resource Disposal 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.