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.
Launch Visual Studio 2012. Create a project of type WPF Application and name it
ThreadHandlingWPF
.Open
MainWindow.xml
in the design mode. Design the UI so that it looks similar to the following screenshot:Name the controls as detailed in the following table:
Open
MainWindow...