|
-
Aug 13th, 2010, 08:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Problem with Thread
Hi everyone,
In one application, I need use 4 simultaneous threads.
When the threads finished, I need to update the text of a TextBox.
So, I create 4 Textbox, and I wanna the threads change the text to FINISHED.
Each thread change one distinct TB.
I use this "example" code:
Code:
Dim Terminados As Integer = 0
Private Sub frmEnviarMensagem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Start()
Dim t1 As New Thread(AddressOf tarefa1)
Dim t2 As New Thread(AddressOf tarefa2)
Dim t3 As New Thread(AddressOf tarefa3)
Dim t4 As New Thread(AddressOf tarefa4)
t1.Start()
t2.Start()
t3.Start()
t4.Start()
End Sub
Private Sub tarefa1()
tbPlaca1.Enabled = True
tbQtd1.Enabled = True
tbPlaca1.Text = "TERMINADO..."
Terminados = Terminados + 1
End Sub
The problem is, I have an error in the red lines.
The error is:
INVALIDOPERATIONEXCEPTION
"Cross-Thread operation not valid: Control tbPlaca1 Accessed from a thread other than the thread it was created on."
I don't use cross threading. Each TB only was accessed for the correspondent thread, and for the "main program".
How can I do this??
Thnak You
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|