I’ve got a simple asmx web service that just needs to log some information to a transactional database. However it is timing out for the client. The call to update the database just calls 1 stored procedure and I don’t beleive it could be optimized further for better performance. I’ve been reduced to just logging the run using log4net and then reading the log in by a separate process that updates the database.
I was wondering if there is a better way to do this. I was wondering if there is a way to make my code do something like:
public bool method(...) { LogRun(...) Asynchronously call method to insert transaction return true; }
EDIT: I was wrong about BackgroundWorker. So I chaged it to the Thread version, tested.
If you want the work done asynchronously, you can study how to start another thread.
It would take 10 seconds for Log method to finish processing if the Thread.Sleep(10000) line is in the Log method itself. However, with Thread a, The Log method will return immediately after call.
Also note that, there is no easy way to guarantee the calling client if the insert operation is completed or not, with this style of asynchronous call.