AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Threading in vb.net 2005
Posted by RAVI KHARVI on  6/14/2008 7:40:26 AM Category: VB.NET
Add to my favorites
Email to friend
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

Post Your Reply Post New Question

 Viewer's Reply
This Question has 0 replies.

 
Sponsored by
SearchSAP
Oracle Magazine
When Good HTML Goes Bad: How You Can Protect Your Web Applications