ASP.Net client updates results of Async Web Service call SOMETIMES. Thread timeout?

pkloeb

Member
Joined
Sep 4, 2013
Messages
7
Programming Experience
1-3
When we call a webservice method Asyncronously that calls a stored procedure in DB2, it will update the web client with the results IF it is a 5-6 minute wait but it will not if it runs 13 minutes (our two longest waits)

Code:

Protected Sub btnAsync_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAsync.Click

Dim wsVSPS As New VSPSDS.ShelfDS

AddHandler wsVSPS.calculatePassFailCompleted, New VSPSDS.calculatePassFailCompletedEventHandler(AddressOf wsVSPS_Complete)
wsVSPS.calculatePassFailAsync("S2013099")

End Sub

Sub wsVSPS_Complete(ByVal sender As Object, ByVal e As calculatePassFailCompletedEventArgs)
txtResults.Text = e.Result
End Sub


I added a line of code to write to the event log the e.Results in the call back function and it writes the correct results, but for some reason, the txtResults.Text box will not update with the 13 minute wait for the long procedure call, 13 minutes, but it will with the 6 minute wait. All timers have been set to 40 minutes: Web Config httpRuntimeExecution, the page asynctimeout (<%@ Page Language="VB"...Async="true" AsyncTimeout="2400"... %>, the setting in the IIS, and the AsyncPostBackTimeout setting in the <asp:ScriptManager AsyncPostBackTimeout="2400"......>

Just wondering if there is some 10minute thread timeout setting somewhere that I'm missing? Is there something I should do to keep the thread alive?

We also used the legacy aysnc calls with BeginWebMethod and EndWebMethod and had the operation wait, but that had the same behavior as I described above.

Thanks,
Kevin
 
Threads have no timeout. They just run what you tell them to run. You should probably start by figuring out WHY the call takes 13 minutes in the first place. Most likely there is a exception in the service escaping from your procedure before it returns results.
 
Herman,

Thanks. While I agree 13 minutes is a long time, it is what we have to work with as that is on the Database side and it is doing calculations. The stored procedure returns a 'F' for Fail and a 'C' for complete. In the call back function, wsVSPS_Complete, I put in a write to the Event Log and I get a 'C' at the completion of the 13 mintues, but it doesn't update the Text Box. We just don't understand why since it works on the 5-6 minute calculation.

Sub wsVSPS_Complete(ByVal sender As Object, ByVal e As calculatePassFailCompletedEventArgs)
EventLog.WriteEntry("Async State", e.Result, EventLogEntryType.Information, 18000, Ctype(3,Short))
txtResults.Text = e.Result
End Sub

In short, it writes the results to the Event Log, but not to the text box. Strange and has us bottlenecked. If you have any other ideas, I would appreciate it.

Regards,
Kevin
 
For extra information, a programmer here came up with something that works, but it isn't 'clean' and we are not sure why it works and all the other ways don't.

WebPage 1 on the Button_Click Event we set a session variable and call redirect to another page that does the async operations and once done, Redirects back to the calling page.:

SurveyCalc.aspx

page_Load(ByVal Sender as Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
txtResults.text=Session("SURVEYCALCREPLY")
End If
End Sub


Protected Sub btnAsync_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAsync.Click

txtResults.text=""
Session("ID")=strSurveyID
Response.Redirect("AsyncCalculation.aspx", False)

End Sub


on the AsyncCalculation.aspx page we have the following code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler Me.PreRenderComplete, New EventHandler(AddressOf Page_PreRenderComplete)
Page.AddOnPreRenderCompleteAsync(New BeginEventHandler(AddressOf BeginAsyncOperation), New EndEventHandler(AddressOf EndAsyncOperation))
End Sub

Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("SurveyCalculations.aspx", False)
End Sub

Function BeginAsyncOperation(ByVal sender As Object, ByVal e As EventArgs, ByVal cb As AsyncCallback, ByVal state As Object) As IAsyncResult
Dim dal As New SurveyDAL
Return dal.calculateSurveyPassFailAsync(Session("ID"), cb, state)
End Function

Sub EndAsyncOperation(ByVal ar As IAsyncResult)
Dim dal As New SurveyDAL
Dim strResults As String = "Fail"
strResults = dal.calculateSurveyPassFailAsyncEnd(ar)
If strResults= "C" Then
Session("SURVEYCALCREPLY") = "Survey calculations were completed successfully for survey : " & Session("ID") & _
"<a href='Reports/CalculationsResults.aspx?ID=" & Session("ID") & "'>Select options and view details</a>"
ElseIf strResults = "F" Then
Session("SURVEYCALCREPLY") = "Survey Calculations Failed. Contact the help desk."
Else
Session("SURVEYCALCREPLY") = "An unknown error has occured. " & strResults & " Please contact the help desk."
End If
End Sub
End Class


This all works, but why doesn't the old BeginWebMethod/EndWebMethod or the Async Event models ?
 
Let me put is this way, which I hope is better. I'm using 'Asynchronous Pages', but when the Asynchronous operation is done, the results are written to the Event Log, however, any code that pertains to the page doesn't not work. ie txtTextBox.text=Results or Response.Redirect commands. Nothing works but the event log writes the expected results. It's just weird.
 
Back
Top