I have this function...
Instance(uint InstanceId) { }
Inside it is this code...
mUpdater = new Timer(new TimerCallback(PerformUpdate), null, TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500));
It refreshes PerformUpdate every 500 milliseconds
In PerformUpdate i have a IF statement to calculate if a user has a specfic variable defined. How would I make it so if a user has the variable, then it only refreshes every 300 milliseconds instead of 500.
Oh and it cannot be set inside the Instance function as its a per user command and Instance is for every user.
Help would be much appreciated!
This looks like it's for the System.Threading.Timer
, not System.Timers.Timer
, correct? You can call the Change
method on a System.Threading.Timer
to change its start time and interval.
var variableDefined = true;
var threadingCallback = new System.Threading.TimerCallback((o) => { });
var threadingTimer = new System.Threading.Timer(threadingCallback, null, 0, 500);
if (variableDefined) {
threadingTimer.Change(0, 300);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.