Reputation: 7733
I have a client-server application with SQL server on the backend.
I am running some resource intensive task (takes around 30 hours to complete). The user is given 3 minutes of Session. Every 2 minutes I have a separate thread renewing the session.
However, once in a while the thread is paused because the garbage collector activates and blocks the threads. Because of this by the time the thread wakes up the session is already expired, so I can not finish my tasks.
I am using Workstation Concurrent setting for my process.
Any suggestions on solving this problem?
In one test, I have a .NET timer set to call its callback every 2 minutes during my task. However, I gradually see that the timer fires in 2min1sec, 2min2sec, and sometimes with over a minute of delays.
Upvotes: 2
Views: 1447
Reputation: 3519
If you are willing to switch to server GC (which looks like a viable option from the discussion), you can use the GC notifications API:
http://msdn.microsoft.com/en-us/library/system.gc.waitforfullgcapproach.aspx
Then, you'll be able to receive a notification just prior to a full GC starting - which would cause pauses.
Upvotes: 1
Reputation: 70307
You can tell the garbage collector to not run during critical operations using the Latency Mode setting.
http://www.infoq.com/news/2012/03/Net-403
http://msdn.microsoft.com/en-us/library/bb384202(v=vs.110).aspx
Upvotes: 0