highwingers
Programmer
I am using BeginInvoke to get a thread from ThreadPool, it all works well, however I need to show an indicator on GUI, that process has finished or something.
like update a Label control... or maybe via javaScript?
here is code... ( look at sub ok() )
Imports System.Threading
Imports System.Runtime.Remoting.Messaging
Partial Class Delegates_Default2
Inherits System.Web.UI.Page
Private Delegate Sub iLoop(ByRef i As Int32)
Public ustr As String = "Khan"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim a As iLoop
Dim ar As IAsyncResult
a = New iLoop(AddressOf Looper)
ar = a.BeginInvoke(0, New System.AsyncCallback(AddressOf imDone), Nothing)
End Sub
Private Sub imDone(ByVal ar As IAsyncResult)
Dim objResult As AsyncResult
Dim mDel As iLoop
Dim myI As Int32
objResult = CType(ar, AsyncResult)
mDel = objResult.AsyncDelegate
mDel.EndInvoke(myI, ar)
System.Diagnostics.Debug.WriteLine(myI & ":Callback Finished")
Me.ok(ustr) '< --------------
End Sub
Private Sub Looper(ByRef i As Int32)
Dim availableThreads As Int32
Dim b As Int16
For j As Int32 = 1 To 30
System.Diagnostics.Debug.WriteLine(j & ":Callback Started")
Next
ThreadPool.GetAvailableThreads(availableThreads, b)
System.Diagnostics.Debug.WriteLine(i)
System.Diagnostics.Debug.WriteLine("This Value:" & i & ":avail Threads:" & Thread.CurrentThread.IsThreadPoolThread.ToString() & ":" & availableThreads & ":Current Thread" & Thread.CurrentThread.GetHashCode())
End Sub
Private Sub ok(ByVal d As String)
' I AM DONE, Show something to User
End Sub
End Class
like update a Label control... or maybe via javaScript?
here is code... ( look at sub ok() )
Imports System.Threading
Imports System.Runtime.Remoting.Messaging
Partial Class Delegates_Default2
Inherits System.Web.UI.Page
Private Delegate Sub iLoop(ByRef i As Int32)
Public ustr As String = "Khan"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim a As iLoop
Dim ar As IAsyncResult
a = New iLoop(AddressOf Looper)
ar = a.BeginInvoke(0, New System.AsyncCallback(AddressOf imDone), Nothing)
End Sub
Private Sub imDone(ByVal ar As IAsyncResult)
Dim objResult As AsyncResult
Dim mDel As iLoop
Dim myI As Int32
objResult = CType(ar, AsyncResult)
mDel = objResult.AsyncDelegate
mDel.EndInvoke(myI, ar)
System.Diagnostics.Debug.WriteLine(myI & ":Callback Finished")
Me.ok(ustr) '< --------------
End Sub
Private Sub Looper(ByRef i As Int32)
Dim availableThreads As Int32
Dim b As Int16
For j As Int32 = 1 To 30
System.Diagnostics.Debug.WriteLine(j & ":Callback Started")
Next
ThreadPool.GetAvailableThreads(availableThreads, b)
System.Diagnostics.Debug.WriteLine(i)
System.Diagnostics.Debug.WriteLine("This Value:" & i & ":avail Threads:" & Thread.CurrentThread.IsThreadPoolThread.ToString() & ":" & availableThreads & ":Current Thread" & Thread.CurrentThread.GetHashCode())
End Sub
Private Sub ok(ByVal d As String)
' I AM DONE, Show something to User
End Sub
End Class