开发者

How can I avoid App Pool termination during long-time ASP.NET calculations?

My hosting provider gave me 50% cpu limitation. I'm trying to use DotNetZip to backup my DNN portal files -- the c开发者_如何学JAVAollection of more than 16000 files of 600Mb disk-space. I'm using a separate thread with the lowest priority for compression. If the processor is loaded enough then my thread works fine but when the processor is more or less free I rich quickly my CPU limitation (50%) and finally the pool terminates and needs to be recycled.

So I need an idea how I can slow down the thread in order not to exceed the cpu limitation.

Thanks.


If you just want to keep the thread below 50% utilization, sprinkle Thread.Sleep(x) throughout the code. You'll need to figure out how many of these you need, and what the millisecond delay should be -- and that's only if you wrote the code that needs the Sleep() calls...

That said, your situation sounds rather odd. There should be a better way to make your backup.


The simplest approach would probably be to throw in a Sleep regularly, with enough time specified so that thread cannot, even if nothing else is ready to run, it is using less that half of one core.


workerThread.Suspend ()
Thread.Sleep (500);
workerThread.Resume ();

Watch out, though. Caution, there is potential to cause deadlocks or unintended slowdowns if the worker thread is in a critical section while you suspend it. For more information: MSDN System.Threading.Thread.Suspend

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜