Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET缓存依赖项脱离线程池_Asp.net_Caching_Multithreading_Dependencies_Threadpool - Fatal编程技术网

ASP.NET缓存依赖项脱离线程池

ASP.NET缓存依赖项脱离线程池,asp.net,caching,multithreading,dependencies,threadpool,Asp.net,Caching,Multithreading,Dependencies,Threadpool,在异步http处理程序中,我们将项添加到ASP.NET缓存中,并依赖于某些文件。如果异步方法在线程池中的线程上执行,则一切正常: AsyncResult result = new AsyncResult(context, cb, extraData); ThreadPool.QueueUserWorkItem(new WaitCallBack(DoProcessRequest), result); 但当我们尝试在线程池外的线程上执行时: AsyncResult result = new Asy

在异步http处理程序中,我们将项添加到ASP.NET缓存中,并依赖于某些文件。如果异步方法在线程池中的线程上执行,则一切正常:

AsyncResult result = new AsyncResult(context, cb, extraData);
ThreadPool.QueueUserWorkItem(new WaitCallBack(DoProcessRequest), result);
但当我们尝试在线程池外的线程上执行时:

AsyncResult result = new AsyncResult(context, cb, extraData);
Runner runner = new Runner(result);
Thread thread = new Thread(new ThreadStart(runner.Run());
。。。其中Runner.Run只调用DoProcessRequest

依赖项确实会在线程退出后立即触发。即,项目立即从缓存中删除,原因是依赖项

我们希望使用池外线程,因为处理可能需要很长时间

很明显,当我们创建线程时,缺少了一些东西。我们可能需要传播调用上下文、http上下文

有人遇到过这个问题吗


注意:现成的自定义线程池可能会解决这个问题。编写我们自己的线程池可能是个坏主意(想想NIH综合症)。但我想详细了解这一点。

无法理解细节。。。 但是找到了一个解决方法:在大多数IAsyncResult实现中,一旦操作完成,就会直接调用回调。我们替换了它,现在将回调排入线程池。因此,回调在线程池中执行,并且可以注册持续的依赖项