I have a web application that a user puts some data into some fields and then clicks the process button.
Server Side code gets executed and starts to run the process. It makes a call to a web service and the web service returns an object that has data in it along with an image.
after it gets the object from the web service the server side code executes a lot more procedures that can take some time. This is where the problem lies.
My users need the image to print as soon as possible and do not want to wait the extra 4 - 5 seconds the rest of the process takes.
Protected Delegate Sub AsyncCallDelegate()
Private _asyncCallDelegate As AsyncCallDelegate
Web service call function
Dim t As New Thread(New ThreadStart(AddressOf ThreadForAsync))
End of function
Private Sub ThreadForAsync()
Dim task As New PageAsyncTask(New BeginEventHandler(AddressOf BeginAsyncOp), New EndEventHandler(AddressOf EndAsyncOp), New EndEventHandler(AddressOf TimedOutOp), Nothing)
Private Function BeginAsyncOp(ByVal sender As Object, ByVal e As EventArgs, ByVal cb As AsyncCallback, ByVal state As Object) As IAsyncResult
' Me.Report = "Begin Async"
_asyncCallDelegate = New AsyncCallDelegate(AddressOf AsyncCall)
Return _asyncCallDelegate.BeginInvoke(cb, state)
Private Sub EndAsyncOp(ByVal ar As IAsyncResult)
' Report = "End Async"
blnAsynTimeOut = False
Private Sub TimedOutOp(ByVal ar As IAsyncResult)
' Report = "Timed Out"
blnAsynTimeOut = True
Private Sub AsyncCall()
Dim strRunScriptASync As String = ""
strCarrierType = objGenericCarrier.CheckCarrierType(strCarrierSelect, DDLPlantID.SelectedValue)
If strCarrierType = Nothing Then
strCarrierType = ""
If strCarrierType.ToUpper = "INTEGRATED" Then
If strIntegratedTrackingNo.Count > 0 Then
For rc As Integer = 0 To strIntegratedTrackingNo.Count - 1
'This function here just creates the java script.
strRunScriptASync &= DirectPrintLable(strIntegratedTrackingNo(rc), strCarrierSelect, DDLServiceType.SelectedValue)
If strRunScriptASync <> "" Then
'ScriptManager.RegisterStartupScript(Me, Me.GetType(), "RunAllPopups", strRunScript, False)
ScriptManager.RegisterStartupScript(UpdatePanelAsync, UpdatePanelAsync.GetType(), "RunAllPopups", strRunScriptASync, False)