Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2
You last visited: Today at 08:38

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Timer Question

Discussion on Timer Question within the Conquer Online 2 forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Timer Question

I have a question about Timers.
Well, really a question of "Am I doing this right?" =P

So, its the LOTF source, and this code is in General.cs.

So I have a Timer, and I'll show you what I have.

Code:
public static System.Timers.Timer Timer;
Code:
Timer = new System.Timers.Timer();
Timer.Interval = 300000;
Timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
Timer.Start();
Code:
public static void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
    //STUFF HAPPENS
}

Is this the proper way to set up a timer? Or would I need some more coding. Thanks!


Also, how are the Intervals set up? like, how would I do 15 seconds for example?
kinshi88 is offline  
Old 07/19/2008, 21:03   #2
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Intervals are in milliseconds;
1 second = 1 000 milliseconds
So 15s in milliseconds = 15 * 1000 = 15000

Personally I think the System.Timers.Timer sucks, I prefer the System.Threading.Timer, it's faster (run-time) and more simplistic.
InfamousNoone is offline  
Thanks
1 User
Old 07/19/2008, 21:16   #3
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
So to change to System.Threading.Timer, I would just change Timers to Threading right?

And if you could, whats the difference between Timers and Threading?


So to get say 15 minutes, I would go 15 x 60 x 1000 right?
kinshi88 is offline  
Old 07/19/2008, 23:21   #4
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Yep, thats all you gotta do (for 15 minutes). The difference between the timer.timer and threading.timer is the way the "underlying" code works (the code Microsoft wrote). The threading.timer run runs faster because it is doing less work and setting up less information the the timer.timer.

Though I wrote my own timer class to process handling, I've rewrote a lot of Microsoft's classes just because most of the code they have is usually bulky and ****.
InfamousNoone is offline  
Thanks
1 User
Old 07/20/2008, 23:28   #5
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Awesome, thanks.

Oh, alright, hey thanks a lot for the explainations!
So threading.timer would take less CPU and stuff right? Awesome, thank you!
kinshi88 is offline  
Old 07/21/2008, 03:24   #6
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Yeah, if your intrested in learning how to make the most low-level efficient timer, look up "WM_TIMER" for "SendMessage"/"PostMessage"
InfamousNoone is offline  
Reply


Similar Threads Similar Threads
Timer
08/04/2010 - CO2 Private Server - 10 Replies
I'm trying to make a timer on how often the /xp skill command can be used but i just cant seem to get it right here's my command #region XP Skill if (Cmd == "/XP" || Cmd == "/xp") { DateTime TillNext = DateTime.Now; DateTime LastUse = GC.MyChar.LastXPCommand.AddMinutes(1); TimeSpan TimeLeft = LastUse - TillNext; ...
Can someone help me with a AFK timer ?
03/09/2010 - CO2 Private Server - 25 Replies
So I saw an AFK timer and it looked pretty cool so I wanted to use it and as you have most likely guest that it was LOTF and LOTF = shit so.... So I was think something like AFK for 10 mins you get auto-kicked and maybe add a code so like if (!==1002) || (!==1038) so like if your in ANY map u get kicked after 10mins of not moving but (!==1002) can be there so I can add a map that does NOT have the Auto AFK timer. So can anyone help me out ? or you can just PM me the code if you dont...
Help with this timer
03/26/2009 - CO2 Private Server - 2 Replies
RestartTimer = new System.Timers.Timer(); RestartTimer.Interval = (120 * 60 * 100);<<Make this Ever hour? RestartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_E); RestartTimer.Start(); Lol what do i put there to make it ever hour im use to just numbers not that
Timer
06/04/2008 - Metin2 - 13 Replies
Hey leute kann mir jemand bitte eine datei programmiern, die nachdem start den pc in 90 mins herunterfährt. :) ich bräuchte ihn für den angelbot;), damit ich ihn starten kann, wenn ich in der schule bin, ohne das der pc umsonst so lang an bleibt.:D
DB Timer
09/16/2005 - General Gaming Discussion - 0 Replies
you can have no DB timer....this is how it works...say you incap someone an you DB click on them if someone else atks you the DB skips an DB's the person...if your dbing someone an a NPC attacks you same effect..so in PvP you can exploit by dueling people that your grouped w/ to get fast DB's on your opponents



All times are GMT +1. The time now is 08:38.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.