Hi,
Thank you verymuch for the articles. I havent's seen those yet. I have seen and followed all the exampled of others post, though. To take the example from above. I make some modifications.
What I want is:
1. To be able to provide a callback to function 'Working'
2. The callback function should not need to know if it is called by othere threads. It should just work, and the threading "Invoke" stuff should happen in "Working"
Delegate Sub writetext(ByVal text As String)
Public Sub info(ByVal richbox As RichTextBox, ByVal sleeping As Integer)
Me.rtb = richbox
Me.sleeper = sleeping
End Sub
// next line changed
Public Sub Working(byval w as writetext)
For i As Integer = 0 To 10
// next line changed
w(i.ToString())
Thread.Sleep(sleeper)
Next i
End Sub
Public Sub Writing(ByVal text As String)
// I don't want to deal with this"invoke" here.I'd like to hide it into function"working"
If (Me.rtb.InvokeRequired) Then
Dim f As writetext = New writetext(AddressOf Writing)
rtb.Invoke(f, text)
Else
Me.rtb.AppendText(text & vbNewLine)
End If
End Sub