Hello,
My app basically lists folders and files stored in a specific folder on my server. Since several users’ session may modify the folder’s content (as can an administrator logged using FTP or other means), I need to periodically monitor for the current folder. Currently, if the folder.count changes from the last listing, I refresh the list. For not overloading the server and network, I’ve decided to check every 5 seconds. Is that too much/too low? I don’t know
Also, if a folder or file gets a different name, I won’t notice that. Would it be efficient enough to always list the whole folder (without subfolders) to compare what’s in the list against what’s in the folder?
Anyway, back to topic. I can’t use a WebTimer, because the files and folders are stored on the server; even if it’s possible to ask the server from the browser for the list of items in the folder, I’d want to avoid sending the server a command every 5 seconds while changes are unlikely to have happened.
So I’m left with the regular Timer
which doesn’t understand in which session it runs
I’m confused about that fact and how to deal with it.
Each timer object exists in a given session (or nil, perhaps), right? It can’t exist in several sessions at once. So, if it doesn’t know about its own session, I guess it’s the caller that isn’t related to a given session; in this case, how does the caller even know the timer exists? All that makes me wondering why a timer can’t know its belonging session.
Ok, the timer not knowing its session is a fact. How to deal with it? I first tried to add a property (MySession as WebSession) in the parent page. However, since my session has global methods to deal with items (like CanLoggedUserDoActionOnItem), I can’t have a WebSession property. Defining the property as MySession as Session resolves that, but then my various classes still use the regular session (which is nil since again invoked from a timer). Perhaps I could define a global property, accessed from all my classes but where would I put it (not in the session, as it’s nil; other non-session dependent locations would not be suitable)?
Then I found about the WebSessionContext thing. The documentation is rather poor on the subject: the example shows how to have a WebSessionContext to hold a session and use each session in a loop. That’s somewhat equivalent to using a property in my window (both ways hold a reference to a session and lack a location to access the property).
Timer.CallLater was my final guess. Session is still nil there and the call fires only once, so clearly not the right way.
At this point, I’m lost
(P.S.: sorry for the long post(s) I make; I usually try a lot before asking, so I must provide what I’ve already tried to let others know what I did).