2.5 KiB
title, description, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | description | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| How to: Implement a Form That Uses a Background Operation | Learn how to implement a Windows Form that uses a background operation so that one operation can continue to run while another operation proceeds. | 03/30/2017 |
|
|
9f483f93-1613-4be1-a021-b4934e9c78f3 |
How to: Implement a Form That Uses a Background Operation
The following example program creates a form that calculates Fibonacci numbers. The calculation runs on a thread that is separate from the user interface thread, so the user interface continues to run without delays as the calculation proceeds.
There is extensive support for this task in Visual Studio.
Also see Walkthrough: Implementing a Form That Uses a Background Operation.
Example
[!code-cppSystem.ComponentModel.BackgroundWorker#1] [!code-csharpSystem.ComponentModel.BackgroundWorker#1] [!code-vbSystem.ComponentModel.BackgroundWorker#1]
Compiling the Code
This example requires:
- References to the System, System.Drawing, and System.Windows.Forms assemblies.
Robust Programming
Caution
When using multithreading of any sort, you potentially expose yourself to very serious and complex bugs. Consult the Managed Threading Best Practices before implementing any solution that uses multithreading.