Multithreading in Windows Forms
Much of the .NET framework is not considered thread-safe. This means that it isn't safe to invoke operations directly from one thread to a method in a .NET framework class. This is especially true of Windows Forms controls.
However, this doesn't mean you can't use multithreading in Windows Forms applications; it just means you have to be careful when you do. When interacting with the .NET framework, you need to use the synchronous Invoke or asynchronous BeginInvoke and EndInvoke methods to interact with Windows Forms controls. (You can call Invoke, BeginInvoke, EndInvoke, and CreateGraphics across threads safely.)
Listing 6.13 demonstrates how to interact with Windows Forms. The code simulates an animated graphic. ...
Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.