AddTimer method removal/stop

cbeechcbeech sagði

fyrir löngu síðan | Færsla #1
Hey all - I've looked around for this a good deal including searching the C# doc references and forums. it seems as though (and I'm a noob to C#) you need to use something like 'removeHandle' method to stop a Timer call from executing. however, after trying several different combinations of this and even attempting to assign the AddTimer method to a new Timer instance variable - i can't seem to get by a lot of errors. I realize that the AddTimer method is a Nonoba API method, and I think that this may be part of the issue, and there is (from what i can see in the docs here) no 'stopTimer' type of method to accomplish this in the API package class.

Does anyone have any thoughts on this subject or a solution? thanks :)

MysteryMystery sagði

fyrir löngu síðan | Færsla #2
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.

cbeechcbeech sagði

fyrir löngu síðan | Færsla #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!

OliverOliver sagði

fyrir löngu síðan | Færsla #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

cbeechcbeech sagði

fyrir löngu síðan | Færsla #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!

Svara þræði

Skráðu þig núna til að svara þráðum

Spilatorg

Velkomin(n) á spilatorg.is. Spilatorg er sjálfstæð leikjasíða þar sem þú getur spilað bæði einstaklings- og fjölspilunarleiki frítt.

Tól hönnuða

Ef þú ert flash leikja hönnuður, þá erum við með nokkur frábær tól til að hjálpa þér að búa til jafnvel enn betri leiki.

Frábærir leikir

Af hverju prófarðu ekki nokkra af bestu flash netleikjunum sem við erum með, algjörlega frítt?

Copyright ©2007-2012 Spilatorg™ - All rights reserved.362.0207ms on SERVER34097