Multi-Threading and Delegates Tutorial in VB .NET

This guide will show you everything you need to create a non-GUI multi-threaded application in VB .NET.

There are 2 ways of using multi-threading in VB .NET. First by making use of delegates which I will explain here. And second by programming the threads manually (not actually more complicated).

Using delegates, .NET helps simplify the entire process of using a separate thread and saves you from having to manage the parameter passing, result retrieving and timing issues. Read More…

Invoke UI Changes Across Threads on VB .Net

I need to do this all the time and don’t have the best memory in the world. Today, I decided that I looked this up one too many times so here’s my solution to this multithreading problem:

The Problem:

You try to modify UI components created in one thread in another thread. In VB, you can only make UI changes on the same thread that created it so you get a nice “Cross thread operation not valid” exception.

Here’s the wrong code:

thread = New System.Threading.Thread(AddressOf DoStuff)
Private Sub DoStuff()
    'error occurs here'
    Me.Text = "Stuff"
End Sub

Read More…

 Scroll to top