ADO DOT NET
Centurion
- Joined
- Dec 20, 2006
- Messages
- 160
Hello everyone
I found this great sample from MSDN:
This clearly shows how to set the text of a text box on a thread.
I am new to threading and have some problems with that.
For example, I do not need to set the text inside the text box, but I need to disable the text box.
So, something is still complicated for me:
How should I change the following lines to meet my need?
---
Delegate Sub SetTextCallback(ByVal [text] As String)
---
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
---
Please help me to learn this important issue of programming
I found this great sample from MSDN:
Visual Basic:
Imports System
Imports System.ComponentModel
Imports System.Threading
Imports System.Windows.Forms
Public Class Form1
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim thRead As New Thread(New ParameterizedThreadStart(AddressOf myThread))
thRead.Start()
End Sub
Private Sub myThread(ByVal o As Object)
Me.SetText("a")
End Sub
Private Sub SetText(ByVal [text] As String)
If Me.TextBox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.TextBox1.Text = [text]
End If
End Sub
End Class
I am new to threading and have some problems with that.
For example, I do not need to set the text inside the text box, but I need to disable the text box.
So, something is still complicated for me:
How should I change the following lines to meet my need?
---
Delegate Sub SetTextCallback(ByVal [text] As String)
---
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
---
Please help me to learn this important issue of programming
Last edited: