ajax - BeginInvoke method and Session State -
i invoking asynchronous pagemethod
call client-side. backend code
[webmethod(enablesession = true)] public static string beginmethodcall() { //session accessible here string g = guid.newguid().tostring(); func<object> f = () => methodcall(); iasyncresult asynccall = f.begininvoke(null, f); lock (asyncthreadpool) asyncthreadpool[g] = asynccall; return g; } [webmethod(enablesession=true)] public static object endmethodcall(string guid) { iasyncresult callresult; lock (asyncthreadpool) { callresult = asyncthreadpool[guid]; asyncthreadpool.remove(guid); } func<object> f = (func<object>)callresult.asyncstate; callresult.asyncwaithandle.waitone(); return f.endinvoke(callresult); } [webmethod(enablesession = true)] public static object methodcall() { //session not accessible here }
session state accessible beginmethodcall()
, endmethodcall()
not methodcall()
.
can tell me why lose session state here?
- do threads lose session context because asyn calls not thread safe?
- is there way access session here?
in case may find useful
beginxxx create new theard , threads not session safe obvious reasons
Comments
Post a Comment