I’ve got a single statement running on a ASP.NET page that takes a long time (by long I mean 100ms, which is too long if I want this page to be lightning fast) , and I don’t care when it executes as long as executes.
What is the best (and hopefully easiest) way to accomplish this?
The easiest way is probably to get it to execute in the threadpool. For example, to make this asynchronous:
using System;
using System.Threading;
Change the first line of
Mainto:Be aware that if you pass any arguments in, they’ll be captured variables – that could have subtle side-effects in some cases (particularly if you use it in a loop).