|
|
|
Threading in vb.net 2005 |
|
Posted by
RAVI KHARVI
on
6/14/2008 7:40:26 AM |
Category:
VB.NET |
|
|
|
|
Adding to your Favorites....
|
|
 |
 |
|
|
i am getting the follwing error while display data on label control.
Cross thread operation not valid: Control "Label name " accessed from a thread other than the thread it was created .
Please send a answer as possible as early.
with regards,
ravi.
-------code-------------
Imports System
Imports System.Threading
Public Class Form1
Dim t As Thread
Private Sub BackgroundProcess()
Dim i As Integer = 1
Do While True
txtName.Text = txtName.Text + "hi"
i = 1
Loop
End Sub
Public Sub SetName(ByVal text As String)
txtName.Text = text
End Sub 'SetName
Public Function GetName() As String
Return txtName.Text
End Function 'GetName
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
t = New Thread(AddressOf Me.BackgroundProcess)
' t = New Thread(New ThreadStart(AddressOf Me.BackgroundProcess))
End Sub
Private Sub rdbRun_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbRun.CheckedChanged
t.Start()
End Sub
End Class |
|
|
|
|
|
|
|
|
|
Viewer's Answers |
|
|
|
This Question has 0 replies. |
|
|
|
|
|
|