Posts

Showing posts from September, 2013

VB.Net Cross Thread Events in WinForms

Today I quickly did a proof of concept on integrating a third part component into a winforms application and had to figure out how to raise events on the Windows Forms UI thread from a different one. There are plenty of examples of doing this in C# but they didn't quite translate to VB.Net. Although a BackgroundWorker may have worked I had some more complex requirements. Therefore I slightly tweaked a C# cross thread example on stackoverflow and combined it with another example of building a custom event. Here is what I came out with. I have to investigate better ways of doing this but since there is a lack of any VB.Net examples I thought I would post one. Imports System.ComponentModel Imports System.Threading Public Class CrossThreadingExample Private dummyThread As Thread Private ReadOnly crossThreadEventList As New List(Of CrossThreadEventHandler) Public Delegate Sub CrossThreadEventHandler(sender As Object, e As CrossThreadEventArgs) Public Custom E...