Last post Jul 30, 2014 11:27 PM by Fuxiang Zhang - MSFT
Jul 26, 2014 03:21 AM|852EC327|LINK
A very complicated question wanting you to answer, many thanks first:
Suppose I have two methods at the server side:
1) PageSelectionChanged():string //Create a sessionId for image's rendering.
2) GetImage(sessionId:string):void //Get a specific image according to the sessionId
3) EndSession(sessionId:string):void //End a valid sessionId to make it invalid, because we don't need it anymore.
Now I'm using SignalR to deal with this problem. And you see that because sometimes the image is too large or too complicated to render and the customer has to wait for a long time. I've decided to render twice for the same request:
1st: Create a renderSessionId by calling "PageSelectionChanged" and call "GetImage" to render to a small image to be shown to the public.
2nd: Directly call "GetImage" with the generated sessionId to render a large image to be shown by convering the smaller one to the public.
Now the question is:
Suppose a customer is switching from page to page very quickly, and you see that to render a larger image may take several seconds, and during the "GetImage"'s rendering we need the valid sessionId. But we want is when someone switches from one page to another,
the previous page's sessionId should be ended immediately to save memory on the server and create a new sessionId for the new coming of image to be rendered. But the image, as far as I said above, would be rendered twice and maybe at 2nd time during the rendering
process, the sessionId is ended and this will cause rendering error.
【My ideas & Puzzlings】
1) Using events: PageSelectionChanged should have an event such as UserSwitchEndSession and GetImage should order this event to accept the unexpected page-switch to avoid rendering. However I still don't know when the event occurs, the previous
image's rendering's process (Does it already come into the rendering process?)
2) Signals such as volitale? AutoEventReset?!
3) Any other ideas?
Jul 30, 2014 11:27 PM|Fuxiang Zhang - MSFT|LINK
But we want is when someone switches from one page to another, the previous page's sessionId should be ended immediately to save memory on the server and create a new sessionId for the new coming of image to be rendered.
Thanks for your post.
According to your description, I see you want to end a session variable before switch from current page to another page.
Then you also want avoid the error in method "GetImage" caused by the session id which has ended.
First, for how to end a session before redirect page you can refer to below.
Then, I think you can use the "try catch" statement for the exception in the method "GetImage".
If get such as an exception caused by the invalid session, you can ignore it.