N
Necropony1457
Guest
I'm trying to create a basic idle game like program in a visual studio form using visual basic, but every time that I try to run my program it gives me an error saying "System.InvalidOperationException: 'Cross-thread operation not valid: Control 'PointCounter' accessed from a thread other than the thread it was created on.'" I have the timer initialized when the form loads
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' initalizes timer
TimerGameTick = New Timer(100)
TimerGameTick.Enabled = True
TimerGameTick.AutoReset = True
TimerGameTick.Start()
End Sub
and I have an event set up for the timer
Public Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
IntPoints = IntPoints + IntPointsPerSecond
UpdateScore()
End Sub
and UpdateScore() is
Public Sub UpdateScore()
PointCounter.Text = "Click Points: " + IntPoints.ToString
End Sub
any Idea what I can do to fix this?
Continue reading...
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' initalizes timer
TimerGameTick = New Timer(100)
TimerGameTick.Enabled = True
TimerGameTick.AutoReset = True
TimerGameTick.Start()
End Sub
and I have an event set up for the timer
Public Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
IntPoints = IntPoints + IntPointsPerSecond
UpdateScore()
End Sub
and UpdateScore() is
Public Sub UpdateScore()
PointCounter.Text = "Click Points: " + IntPoints.ToString
End Sub
any Idea what I can do to fix this?
Continue reading...