B
barry
I have a exercise in understanding delegates using beginInvoke and
endInvoke. It runs fine on the windows platform but when I copy the exact
same code into asp.net while it runs without any errors it is not getting
from the worker thread back to the main UI. The code is below. Is there
something specifically differnent in using delegates on the web? Thanks for
any help.
this is all on webform1.aspx.vb
Public Delegate Function DoneDelegate(ByVal stopped As Boolean) As Boolean
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim s As Boolean
s = False
Dim cb As New AsyncCallback(AddressOf AllDone)
Dim del As New DoneDelegate(AddressOf CountStuff)
del.BeginInvoke(s, cb, del)
End Sub
Sub AllDone(ByVal ar As IAsyncResult)
Dim del As DoneDelegate
del = CType(ar.AsyncState, DoneDelegate)
lblResults.Text = (del.EndInvoke(ar) & " records found")
End Sub
Public Function CountStuff(ByVal stopped As Boolean) As Boolean
Dim intOut As Boolean = True
System.Threading.Thread.Sleep(5000)
Return intOut
End Function
endInvoke. It runs fine on the windows platform but when I copy the exact
same code into asp.net while it runs without any errors it is not getting
from the worker thread back to the main UI. The code is below. Is there
something specifically differnent in using delegates on the web? Thanks for
any help.
this is all on webform1.aspx.vb
Public Delegate Function DoneDelegate(ByVal stopped As Boolean) As Boolean
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Dim s As Boolean
s = False
Dim cb As New AsyncCallback(AddressOf AllDone)
Dim del As New DoneDelegate(AddressOf CountStuff)
del.BeginInvoke(s, cb, del)
End Sub
Sub AllDone(ByVal ar As IAsyncResult)
Dim del As DoneDelegate
del = CType(ar.AsyncState, DoneDelegate)
lblResults.Text = (del.EndInvoke(ar) & " records found")
End Sub
Public Function CountStuff(ByVal stopped As Boolean) As Boolean
Dim intOut As Boolean = True
System.Threading.Thread.Sleep(5000)
Return intOut
End Function