joshmag wrote:
Actually we have a very unique situation i guess.
The web service is called by a telephone system. We don't want the user to be waiting on the phone for 30 seconds for the api to return, so i would like all db queries to timeout after 5 seconds..
The timeout doesn't dictate how long the query will take, it dictates when an exception is thrown if it takes longer than that. I doubt your system is that slow that most queries take > 1 second, most databases are faster than that, even sybase Setting it to 5 seconds will give an exception after 5 seconds if the query takes e.g. 6 seconds. Not sure the user would like that too...
Anyway, I will just wrap all db access in a function which sets the command timeout property.
I could also run each db access on another thread and kill the thread after 5 seconds, but i think that could degrade performance in asp.net...
I don't think Sybase driver has non-blocking IO. Their async stuff just blocks.
Of course, i could just ask the client to timeout the request after 5 seconds too..
Killing threads isn't recommended in .net. The sybase ado.net providers are really low quality, so I'm not surprised their async code is just wrapping sync code.