|
You last visited: Today at 15:57
Advertisement
System Timers Question
Discussion on System Timers Question within the CO2 Private Server forum part of the Conquer Online 2 category.
08/12/2013, 17:55
|
#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?
|
|
|
08/12/2013, 18:38
|
#2
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
|
There's more than one "Timer" class in .NET, which are you referring to?
|
|
|
08/12/2013, 18:58
|
#3
|
elite*gold: 0
Join Date: Feb 2006
Posts: 41
Received Thanks: 2
|
System.Timers.Timer
|
|
|
08/12/2013, 23:09
|
#4
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
|
No. You shouldn't use it at all.
|
|
|
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)
|
|
|
08/13/2013, 00:13
|
#6
|
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 81
|
make your own timer on an existing thread.
|
|
|
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.
|
|
|
08/13/2013, 12:31
|
#8
|
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
|
Quote:
Originally Posted by hacksaw
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.
|
|
|
08/13/2013, 12:49
|
#9
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
|
hadeset, the GC is not instantly removing unused memory
|
|
|
08/13/2013, 12:53
|
#10
|
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
|
Quote:
Originally Posted by Super Aids
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.
|
|
|
08/13/2013, 13:18
|
#11
|
elite*gold: 0
Join Date: Feb 2006
Posts: 550
Received Thanks: 81
|
i am surprised a lot of these servers don't run into concurrency issues, throwing tasks on random threads like that, unless they do!
|
|
|
08/13/2013, 13:38
|
#12
|
elite*gold: 0
Join Date: Oct 2006
Posts: 110
Received Thanks: 67
|
Quote:
Originally Posted by ChingChong23
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
|
|
|
08/13/2013, 13:47
|
#13
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
|
Quote:
Originally Posted by hadeset
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
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.
|
|
|
08/19/2013, 23:41
|
#14
|
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
|
Quote:
Originally Posted by Super Aids
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.
|
|
|
08/20/2013, 00:26
|
#15
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
|
One thread per client is exactly when it happens and @ the collections
|
|
|
|
|
Similar Threads
|
Timers Question
05/07/2013 - CO2 Private Server - 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 that for every new player that goes through this it starts a new "TimerB" for each individual player rather than just altering it for every player thats gone through it?
public static System.Timers.Timer TimerB;
public static void...
|
Better way to set Autoinvite timers?
03/09/2013 - CO2 Private Server - 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 is 200-500, it use to be less than 100 on other sources.
Do you suggest a better way to deal with these timers? to be honest, i've no idea what to do
|
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 was guild leader of Requiem and on Abso i was guild leader of Damnation. So if any of u reconize the name or guilds from those servers hit me up looking to try and connect with some of u guys and gals from the past.
|
[Question/Request]Halo Timers
01/19/2010 - CO2 Private Server - 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 long can you remain in the mission map?
Im trying to use Cheat Engine 5.3 but i dont really got the hang of it yet.
and a little explination on how this works would be really helpful.
Please, and Thank You? :)
|
All times are GMT +2. The time now is 15:57.
|
|