Hi Guys,
The info is as follows:
I have a web page that does a very heavy operation. In order to make it a bit more interactive i implemented AJAX on that page (have not used the inbuilt AJAX controls).
The page psuedo code is as follows:
In Page_Load
------------
If CallBy is AJAX then 'I idenfity this with a particular Request.Form item
Return Back Session("RecordCount")
response.end
exit sub
end
'Non AJAX call. This happens only for the first call made to the page
Create a new Thread for a sub called UpdateData()
ClientScript.RegisterStartupScript the JavaScript that will enable AJAX invocation
In UpdateData()
---------------
for loop for around more than 100000 records
Session("RecordCount")=CurrentRecordCount
'Do a heavy operation on each record.
next
The AJAX request will be made every 1 second.
The code is working fine on my system. However when i deploy this to a colleague's system he gets the following error:
System.InvalidOperationException: Collection was modified after the enumerator was instantiated
This error comes once in maybe 20 AJAX requests (the thread continues to execute thereby updating the record count and therefore the next AJAX request gives the correct data count). I was able to capture this error from the AJAX response which i set to a <DIV> tag.
The worst part is that this error is being thrown ONLY at the application level (I identofied this by setting a debug point in the App_error event of Global.asax). I am unable to capture this error at the page level (In the Catch block of Page_Load)!
I also tried playing around with Trace and was able to idenfity one strage aspect with the failing AJAX request.
The session collection appearing for the failed request is virtually empty (even though there are around 10 session values for every user).
I also tried delaying the AJAX request to 5 seconds. No go there.
I also tried using SynchLock commands. This also did not lead me anywhere.
Finally doubting that this could be an issue with locking of the session variable i commented the Session accessing block of AJAX in the page_load.
If CallBy is AJAX then
'Return Back Session("RecordCount")
response.end()
exit sub
end
The error is still being thrown.
One more conclusion that i was able to make is that this error is NOT being thrown by the block executed by the thread code as the next AJAX request gives me the correct value.
My Page_Load event does NOT have any loops on any collections whatsoever.
Currently i am in the process of writing a simple AJAX request and testing the result. But please do let me know if any of you have come across such a strange error.
Known is handfull, Unknown is worldfull
The info is as follows:
I have a web page that does a very heavy operation. In order to make it a bit more interactive i implemented AJAX on that page (have not used the inbuilt AJAX controls).
The page psuedo code is as follows:
In Page_Load
------------
If CallBy is AJAX then 'I idenfity this with a particular Request.Form item
Return Back Session("RecordCount")
response.end
exit sub
end
'Non AJAX call. This happens only for the first call made to the page
Create a new Thread for a sub called UpdateData()
ClientScript.RegisterStartupScript the JavaScript that will enable AJAX invocation
In UpdateData()
---------------
for loop for around more than 100000 records
Session("RecordCount")=CurrentRecordCount
'Do a heavy operation on each record.
next
The AJAX request will be made every 1 second.
The code is working fine on my system. However when i deploy this to a colleague's system he gets the following error:
System.InvalidOperationException: Collection was modified after the enumerator was instantiated
This error comes once in maybe 20 AJAX requests (the thread continues to execute thereby updating the record count and therefore the next AJAX request gives the correct data count). I was able to capture this error from the AJAX response which i set to a <DIV> tag.
The worst part is that this error is being thrown ONLY at the application level (I identofied this by setting a debug point in the App_error event of Global.asax). I am unable to capture this error at the page level (In the Catch block of Page_Load)!
I also tried playing around with Trace and was able to idenfity one strage aspect with the failing AJAX request.
The session collection appearing for the failed request is virtually empty (even though there are around 10 session values for every user).
I also tried delaying the AJAX request to 5 seconds. No go there.
I also tried using SynchLock commands. This also did not lead me anywhere.
Finally doubting that this could be an issue with locking of the session variable i commented the Session accessing block of AJAX in the page_load.
If CallBy is AJAX then
'Return Back Session("RecordCount")
response.end()
exit sub
end
The error is still being thrown.
One more conclusion that i was able to make is that this error is NOT being thrown by the block executed by the thread code as the next AJAX request gives me the correct value.
My Page_Load event does NOT have any loops on any collections whatsoever.
Currently i am in the process of writing a simple AJAX request and testing the result. But please do let me know if any of you have come across such a strange error.
Known is handfull, Unknown is worldfull