Register for your free account! | Forgot your password?

You last visited: Today at 20:19

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


System Timers Question

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2006
Posts: 41
Received Thanks: 2
System Timers Question

When using system timers for say inside an event that runs once per day, Should you always call Timer.Dispose() for each timer after the event ends and you have stopped the timers?



hacksaw is offline  
Old 08/12/2013, 18:38   #2
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,877
There's more than one "Timer" class in .NET, which are you referring to?


InfamousNoone is offline  
Old 08/12/2013, 18:58   #3
 
elite*gold: 0
Join Date: Feb 2006
Posts: 41
Received Thanks: 2
System.Timers.Timer
hacksaw is offline  
Old 08/12/2013, 23:09   #4
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,609
Received Thanks: 829
No. You shouldn't use it at all.


Super Aids is offline  
Old 08/12/2013, 23:44   #5
 
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
An event, that runs once a day? I don't think using a Timer for this occasion is very advisable. I don't know which source kids be using these days, but I'm sure it has a thread somewhere that checks events by DateTime stamps whether they should be called or not on each step. Perhaps that is the place, you should implement that daily event.

However, if you must use a Timer, you can call Dispose if you want. It should not matter that much, because the GarbageCollector should automatically dispose of it anyways, once it has lived its use, or am I wrong? (I imagine Timer's finalizer calls Dispose)
hadeset is offline  
Old 08/13/2013, 00:13   #6
 
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 79
make your own timer on an existing thread.
ChingChong23 is offline  
Old 08/13/2013, 00:20   #7
 
elite*gold: 0
Join Date: Feb 2006
Posts: 41
Received Thanks: 2
Im using Impluses Base 5165 Source, I have been using Timers in daily events and also for certain Player Quests where things are triggered at certain points or have time limits in them, I mainly started using them so everything was kept tidy and all stuff for each individual thing in 1 place for each given event or quest, There is a Thread that keeps check time wise for things like Buffs ect ect. Would there be any advantage to doing away with the timers and moving the timing part into the Thread mentioned above?

And the reason i asked about dispose was just i had someone looking over some code and when they saw Timer.Stop() said you should also use Timer.Dispose() after it, Which i havent been doing so i was just wondering again if that was the correct way to do it or if he was wrong.
hacksaw is offline  
Old 08/13/2013, 12:31   #8
 
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
Quote:
Originally Posted by hacksaw View Post
Im using Impluses Base 5165 Source, I have been using Timers in daily events and also for certain Player Quests where things are triggered at certain points or have time limits in them, I mainly started using them so everything was kept tidy and all stuff for each individual thing in 1 place for each given event or quest, There is a Thread that keeps check time wise for things like Buffs ect ect. Would there be any advantage to doing away with the timers and moving the timing part into the Thread mentioned above?

And the reason i asked about dispose was just i had someone looking over some code and when they saw Timer.Stop() said you should also use Timer.Dispose() after it, Which i havent been doing so i was just wondering again if that was the correct way to do it or if he was wrong.
Like I said, it couldn't hurt to call Dispose yourself, but you don't have to either, because of GarbageCollector, that .Net has.
hadeset is offline  
Thanks
1 User
Old 08/13/2013, 12:49   #9
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,609
Received Thanks: 829
hadeset, the GC is not instantly removing unused memory
Super Aids is offline  
Old 08/13/2013, 12:53   #10
 
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
Quote:
Originally Posted by Super Aids View Post
hadeset, the GC is not instantly removing unused memory
Yeah, but at some point, it does it anyways. Well not removing memory, but calling finalizers, which are supposed to do the memory freeing.
hadeset is offline  
Old 08/13/2013, 13:18   #11
 
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 79
i am surprised a lot of these servers don't run into concurrency issues, throwing tasks on random threads like that, unless they do!
ChingChong23 is offline  
Old 08/13/2013, 13:38   #12
 
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
Quote:
Originally Posted by ChingChong23 View Post
i am surprised a lot of these servers don't run into concurrency issues, throwing tasks on random threads like that, unless they do!
They probably do. :O
hadeset is offline  
Old 08/13/2013, 13:47   #13
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,609
Received Thanks: 829
Quote:
Originally Posted by hadeset View Post
Yeah, but at some point, it does it anyways. Well not removing memory, but calling finalizers, which are supposed to do the memory freeing.
You're better off doing it yourself at some points. Not saying it's necessary in this case, but with streams and such it's highly recommended.

Quote:
Originally Posted by ChingChong23 View Post
i am surprised a lot of these servers don't run into concurrency issues, throwing tasks on random threads like that, unless they do!
Ikr? Well if I am correct Impulse source had a lot of deadlock problems as well.
Super Aids is offline  
Old 08/19/2013, 23:41   #14
 
elite*gold: 0
Join Date: Oct 2009
Posts: 762
Received Thanks: 539
Quote:
Originally Posted by Super Aids View Post
You're better off doing it yourself at some points. Not saying it's necessary in this case, but with streams and such it's highly recommended.



Ikr? Well if I am correct Impulse source had a lot of deadlock problems as well.
Deadlocks hardly. Race conditions, not really either. The source I released used one thread per client so they would be fairly rare. Though, a very well known problem would be the collection modified exceptions which is a result of a lack of locks which do exists in most sources.
-impulse- is offline  
Old 08/20/2013, 00:26   #15
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,609
Received Thanks: 829
One thread per client is exactly when it happens and @ the collections http://msdn.microsoft.com/en-us/libr...oncurrent.aspx


Super Aids is offline  
Thanks
1 User
Reply



« [Help] 5095 source daily pk war NPC | mysql "Set" »

Similar Threads
Timers Question
05/07/2013 - CO2 PServer - Discussions / Questions - 1 Replies
I've been using the following code for specific events to activate things at different times for everyone who is in the event which works fine. But now im looking at using for something different and im wondering if there is a way to make it so...
Better way to set Autoinvite timers?
03/09/2013 - CO2 PServer - Discussions / Questions - 9 Replies
Hello, I'm using a 5672 edited trinity base. There are a lot of auto-invites timers for several events, but it's situated in Threading system, program.cs this is kinda taking a lot of RAMs (+150mb on 0 players), even with a powerful host, ping...
Old Timers
10/03/2012 - Shaiya Private Server - 10 Replies
Hey there Epvp been awhile sense i been around just looking around here. To see if i can find any old guildys or players from either Shaiya Evo or Shaiya Abso. My char name i used on those 2 was Syn or other variations of Syn for alt toons. On Evo i...
[Question/Request]Halo Timers
01/19/2010 - CO2 PServer - Discussions / Questions - 5 Replies
has anyone made the save halo timer and if so could they be kindly and release it. ty
Mission Timers?
11/10/2008 - Ace Online / AirRivals - 15 Replies
Ive seen it said a few times that you can slow down the mission timer for missions such as the Lv.8 Mission, and the ANI Lv.27 Mission. Others claim such things are impossible :P What im really looking to know is... Is it Possible?, and How...



All times are GMT +2. The time now is 20:19.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.