I'm currently using ThreadPool.QueueUserWorkItem in an Asp.Net application. Basically a user uploads a file using a form with an FileUpload Control. The file can take quite a while to process which was causing a time out for the user and also making the UI unusable while the upload was processing. So I thought I'd just call my import method like this:
ThreadPool.QueueUserWorkItem(this.NameOfMyImportMethod);
The data that the import method needs to work on has been as set as class variables when the Import class is constructed (I'm not doing the import work in the code behind!).
This all works fine most of the time. However seemingly at random the import method does NOT get called asynchronously, the browser sits waiting for a response and eventually times out.
I'm ensuring I'm catching all exceptions inside the import method.
I can't recreate it all time but it seems to happen mostly if I play about with the form causing a few post backs before actually submitting.
Any ideas as to what might be going on here?
Thanks for any help!