Samuel

Samuel

  • NA
  • 1
  • 0

Multithread unable to get updated textbox value.

Mar 20 2010 2:24 PM

I encountered problem getting the updated textbox value after i start new thread for my application, any help will be much appreciated. Sequence as follow:
Private
Sub Form1_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   textbox1.text = "aaaa"
End Sub
Private Sub Btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn1.Click
   textbox1.text = "bbbb"

 End Sub
Private Sub StartBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartBtn.Click
   Timer1.Enabled =
True
End Sub

Private Delegate Sub SBODelegate(ByVal i As Integer, ByVal i As Integer)
Private
Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
   Dim del As SBODelegate = New SBODelegate(AddressOf SBOThread)
   Dim res As IAsyncResult = del.BeginInvoke(1, 2, Nothing, Nothing)
End Sub
Private Sub SBOThread(ByVal x As Integer, ByVal y As Integer)
   SBO.SBOGetTextbox()
End Sub
Public
Class SBO
   Public Shared Sub SBOGetTextbox()
      Messagebox.show(textbox1.text)
   End Sub
End Class
Can anybody tell me why the result from the message box is "aaaa", and not "bbbb"?
 
 

 
 

Answers (1)