• After more than 30 years running websites and forums I am retiring.

    I have made many friends through the years. I will cherish my time getting to know you. I wish you all the best. This was not an easy decision to make. The cost to keep the communities running has gotten to the point where it's just too expensive. Security certificates, hosting cost, software renewals and everything else has increased threefold. While costs are up ad revenue is down. It's no longer viable to keep things running.

    All sites will be turned off on Thursday 30 November 2023. If you are interested in acquiring any of the websites I own you can Email Schwarz Network.

Re: Access or SQL


Oct 2, 2011
Re: Access or SQL

Split from http://www.xtremedotnettalk.com/showthread.php?t=101879

I want to catch events in my main form and change the title to match the input from the event. I'm getting errors about crossthreading. Can some one please help me get this small test program working?

Here is the whole code:

Public Class Form1

Private WithEvents Worker As New WorkerClass

Private Sub Worker_ProgressChanged(ByVal Progress As Integer) Handles Worker.ProgressChanged
Me.Text = Progress
End Sub

End Class


Public Class WorkerClass

Public Event ProgressChanged(ByVal Progress As Integer)
Private t As Threading.Thread

Public Sub New()
t = New Threading.Thread(AddressOf MainThread)
t.Name = "BackgroundThread"
t.IsBackground = True
End Sub

Private Sub MainThread()
Dim Progress As Integer = 0
Do Until Progress = 10
Progress += 1
RaiseEvent ProgressChanged(Progress)
End Sub

End Class

Watch The Ides of March Online for Free
Last edited by a moderator:


Sep 4, 2002
Lancashire, UK
Re: Access or SQL

You can't update a UI element from a non UI thread, your ProgressChanged event is being raised on the background thread and as such is causing this problem.

Is there a reason you aren't using the built in BackgroundWorker component as you seem to be emulating it's way of doing things.
Top Bottom