soccerwiz13
Member
I have a client that connects to a remote SQL Server database. When I call dataset.fill(ds), it can take a couple of minutes to retrieve all of the data. I would like to open a form or message with an animated .gif that says "Downloading Data", or something of that nature. Similar to a file copy dialog box when large files are transfered in windows. I have tried using asynchronous events, but they don't seem to work. The code runs completely, and then dies on the form definition. And the UI never comes back. The following is my code. If anyone has any idea, please let me know.
Thanks in advance.
Code:
PrivateSub button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.Click
Dim state AsObject = NewObject
Dim cb As AsyncCallback = New AsyncCallback(AddressOf RemindResult)
Dim dlgt AsNew aSyncDel(AddressOf filldataset)
dlgt.BeginInvoke(cb, state)
frmdownload.showdialog()
EndSub
PublicSub filldataset()
Try
SqlDAVoter.Fill(DSVC.VoterConnections)
Catch ex As Exception
MsgBox(ex.Message)
EndTry
EndSub
PublicSub RemindResult(ByVal ar As IAsyncResult)
Dim strErrors() AsString
Dim StudCb As aSyncDel
Dim flResult AsBoolean
Dim objResult As System.Runtime.Remoting.Messaging.AsyncResult
' Extract the delegate from the AsyncResult
objResult = CType(ar, System.Runtime.Remoting.Messaging.AsyncResult)
StudCb = objResult.AsyncDelegate
' Obtain the result
StudCb.EndInvoke(ar)
frmDownload.Close()
' Output results
EndSub
PrivateDelegateSub aSyncDel()
Thanks in advance.
Code:
PrivateSub button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.Click
Dim state AsObject = NewObject
Dim cb As AsyncCallback = New AsyncCallback(AddressOf RemindResult)
Dim dlgt AsNew aSyncDel(AddressOf filldataset)
dlgt.BeginInvoke(cb, state)
frmdownload.showdialog()
EndSub
PublicSub filldataset()
Try
SqlDAVoter.Fill(DSVC.VoterConnections)
Catch ex As Exception
MsgBox(ex.Message)
EndTry
EndSub
PublicSub RemindResult(ByVal ar As IAsyncResult)
Dim strErrors() AsString
Dim StudCb As aSyncDel
Dim flResult AsBoolean
Dim objResult As System.Runtime.Remoting.Messaging.AsyncResult
' Extract the delegate from the AsyncResult
objResult = CType(ar, System.Runtime.Remoting.Messaging.AsyncResult)
StudCb = objResult.AsyncDelegate
' Obtain the result
StudCb.EndInvoke(ar)
frmDownload.Close()
' Output results
EndSub
PrivateDelegateSub aSyncDel()