O'Reilly logo

.NET Framework 4.5 Expert Programming Cookbook by A.P. Rajshekhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling threads in WPF

In the previous recipe, we looked at the best way to run operations in non-UI/background threads in Windows Forms. The concerns that we addressed for Windows Forms exist for WPF as well. You cannot access any control on the UI thread from the background thread. In such a case, how do you pass data to a UI thread? In this recipe, we are going to discuss the best approach to doing this.

How to do it…

  1. Launch Visual Studio 2012. Create a project of type WPF Application and name it ThreadHandlingWPF.
  2. Open MainWindow.xml in the design mode. Design the UI so that it looks similar to the following screenshot:
    How to do it…
  3. Name the controls as detailed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required