thanks, John
so, I would just make a call in sub ServerThread() to Sub updateUI........
I thought I had to make a separate class with the delegate statement in it
For clarity:
Delegate statements can be put anywhere..
If they are placed in a separate class, they have to be declared public in order to get acces to them from calls outside the class.
Is there any limitation to my procedure, or what are the boundries?
Do you have a short explanation on when beginEnvoke/endEnvoke is used?
I have seen this used also in combination with async operations, but more with separate classes (is there a connection)
I have a similar problem with this one, but no delegate here
Could you take a look at it , it can help me to better understand async
Code:
Dim fs As FileStream
Dim Callback As AsyncCallback
Dim Contents As Byte()
Private Sub fs_StateChanged(ByVal asyncResult As IAsyncResult)
If asyncResult.IsCompleted Then
tbResult.Text = Encoding.UTF8.GetString(contents)
fs.Close()
End If
End Sub
Private Sub knpAsync_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles knpAsync.Click
Me.OpenFileDialog.ShowDialog()
Me.Callback = New AsyncCallback(AddressOf fs_StateChanged)
fs = New FileStream(OpenFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read _
, 4096, True)
ReDim Contents(fs.Length)
fs.BeginRead(Contents, 0, fs.Length, Callback, Nothing)
End Sub
Bookmarks