|Number of votes:||4|
In a project I’m currently working on I need to update some DSS tables when a user is viewing a page. This is not a problem, but sometimes the save method takes a bit to much time.
Since the saving part of the data not necessarily need to be done in that user thread, I have created a Lazy saver class that do the saving in a different thread.
All I needed to do is to implement my DDS classes with an interface ISaveMe and then save the item like this
It is important to remember that all exceptions in a thread that is not suppressed will make the app pool to restart. Therefore is very important to catch all errors.
This saves me sometimes as much as 70-100ms on each page request.