This is the order of my code:
I make multiple
task.factory.startnew(()=> myFunction(myObject, httpSessionState))
I send the System.Web.SessionState.HttpSessionState to myFunction because i dont wait for the tasks to end , so they run in background, and I can’t get session inside myFunction because
System.Web.HttpContext.Current = null.
myFunction calls webservices and stores their result in the httpSessionState object
then I make several ajax calls to get the session values from the server, until I have all the desired values.
PROBLEM:
I cant explain why users get de-logged from time to time. I assume the session becomes null.
All users get delogged at the same time. All session objects probably become null
This usually happens (loosing sessions) when the server process
w3wp.exe restarts (Asp.net application pool).
Usually hosting providers have an upper memory limit per application pool that when reached restarts the pool to avoid hogging the server.
So basically this could mean that your application is eating to much memory (or has memory leaks).
In your situation, this could mean that the Tasks you spawn are too heavy or leaking, which would indicate that you need to check myFunction().
If you need to limit the degree of concurrency to fine tune memory usage:
http://msdn.microsoft.com/en-us/library/ee789351.aspx