Ramblings of a Software Engineer, Amusements of a Geek, Cacophony of a Guitarist, An Entropy Admirer's and an Interesting Character's Musings..
Tuesday, 9 March 2010
Sunday, 28 February 2010
Handling ASP.NET ‘Thread Aborted Exception’
If you would have bumped into ‘Thread Aborted Exception’ in ASP.NET apps when trying to do a lengthy server process, They would have been interesting times fore sure.
Well, Firstly , The ‘Thread Aborted Exception’ happens when the thread serving the request doesn't
finish for a long time. The ASP.NET hosting process aborts this thread after a certain time which can be adjusted in the ‘executionTimeout’ attribute of the ‘httpRuntime’ element in the ‘Web.Config’ file.
<system.web>
<httpRuntime executionTimeout="600" />
</system.web>
By default the executionTimeout="90" seconds.
Although this might solve the problem , this is not a feasible solution primarily because of scalability reasons, i.e increasing the executionTimeout might decrease the throughput of your web app.
I did an interesting workaround this to ‘ping’ the server at intervals just short of the ‘executingTimeout’ parameter. Now, the idea is, if a process/function/routine takes enormous amount of time (which happens to raise the Thread Aborted Exception) to complete because it’s massive., break the process/function/routine into smaller chunks and ping the server at regular intervals. This can be achieved by storing the execution states in a session variable on the server.
Further, this will open up an opportunity to monitor the progress of your process. Say you’ve re-factored the lengthy routine which was a single function to 10 functions. Every time you finish a function, you can update your progress on the client and continue with the next function on the server.
Advantages
1] This will avoid the ‘Thread Aborted Exception’ and
2] Progress can be monitored.
Disadvantages
1] There is an argument that any lengthy processes must not be done on the asp.net thread pool thread and that such processes should be written as a separate windows service. Well, at the end of the day it depends on your business needs. Personally, i feel you need to consider things like will the app be running on business lan or exposed to the internet , how many simultaneous users will it have ?. Will it be running on a cluster or a single server etc..
Sunday, 14 February 2010
Why i turned buzz off!
Google, Why are you invading my privacy!.
I find Google's buzz a terrible breach of users privacy. They are being very cheeky, adding the ‘buzz’ feature without telling users what the hell it’s supposed to do. I never asked for one in the first place anyway, And this is my personal opinion.
I can’t be bothered to buzz around with my contacts or know what they are doing. C’mon Google !. I’ve lost some respect for you today. This is ridiculous. A very offensive approach at creating their own ‘eco’ system for the cloud trying to take the pie away from Facebook and Twitter. (Which i think they are trying to achieve with Android OS).
For me, it brought frustration more than a new found joy and i turned the buzz feature off. Thank god, they have managed to put that feature inside Gmail. And this is how i did it.
1] Open Gmail and navigate to the bottom of the page to find something similar to the below picture and click on ‘turn off buzz’.
Interesting Links