I'd place a premature return somewhere in the timer function,
if(isNotNeeded) return;
* skipped *
// more of the timer function follows
where,
public bool isNotNeeded = false;
and set to true when the timer function is no longer needed. The timer function will still be called, but will skip everything after * skipped *. It may not be the most elegant method (esp. for people who are afraid of globals,) but that has worked for me for most cases.
AddTimer method removal/stop
Mystery dijo
hace mucho tiempo | Publicación #2
cbeech dijo
hace mucho tiempo | Publicación #3 Thanks Mystery - that's exactly what I'd done as a workaround - spot on.
I was just wondering how to actually stop the Timer altogether though, in the event an action was concluded and the game went into another mode (for instance) and perhaps another procedure begins execution. It would be nice to have a bit more control over the Timer, since one of the methods I've been playing with to battle latency, was to set up a 'ping' that originates from the server-side, the concept being that all players are sent a call at regular intervals, evenly distributed, that invokes the client side processing - it actually works pretty well.
btw - congrads on UNO :) nice work!
I was just wondering how to actually stop the Timer altogether though, in the event an action was concluded and the game went into another mode (for instance) and perhaps another procedure begins execution. It would be nice to have a bit more control over the Timer, since one of the methods I've been playing with to battle latency, was to set up a 'ping' that originates from the server-side, the concept being that all players are sent a call at regular intervals, evenly distributed, that invokes the client side processing - it actually works pretty well.
btw - congrads on UNO :) nice work!
Oliver dijo
hace mucho tiempo | Publicación #4 You can either stop the timer by keeping a reference to the Timer returned form the AddTimer() method and calling it's Stop() method, or you can just only use ScheduleCallback() and just stop scheduling them when you don't need them anymore.
Best,
Oliver
Best,
Oliver
cbeech dijo
hace mucho tiempo | Publicación #5 LOL! thanks Oliver! its as simple as that! man, in all my searching through the C# docs, I didn't run across that - hilarious!
I feel like such a noob! lol - 'stop' for cryin out loud! LOL!
I feel like such a noob! lol - 'stop' for cryin out loud! LOL!
Contestar al tema
Regístrate ahora para responder a éste tema
cbeech dijo
hace mucho tiempo | Publicación #1Does anyone have any thoughts on this subject or a solution? thanks :)