* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
2.2 KiB
title, description, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | description | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| How to: Run an Operation in the Background | Learn how to use the BackgroundWorker class to run a time-consuming Windows Forms operation in the background. | 03/30/2017 |
|
|
5b56e2aa-dc05-444f-930c-2d7b23f9ad5b |
How to: Run an Operation in the Background
If you have an operation that will take a long time to complete, and you do not want to cause delays in your user interface, you can use the xref:System.ComponentModel.BackgroundWorker class to run the operation on another thread.
The following code example shows how to run a time-consuming operation in the background. The form has Start and Cancel buttons. Click the Start button to run an asynchronous operation. Click the Cancel button to stop a running asynchronous operation. The outcome of each operation is displayed in a xref:System.Windows.Forms.MessageBox.
There is extensive support for this task in Visual Studio.
Also see Walkthrough: Running an Operation in the Background.
Example
[!code-csharpSystem.ComponentModel.BackgroundWorker.Example#1] [!code-vbSystem.ComponentModel.BackgroundWorker.Example#1]
Compiling the Code
This example requires:
- References to the System, System.Drawing and System.Windows.Forms assemblies.