Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
c# timers

 
Post new topic   Reply to topic Printable version
 View previous topic  help with strncpy Post :: Post .dll to relate my c# program with wina...  View next topic  
Author Message
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Tue Aug 26, 2008 9:29 pm    Post subject: c# timers Reply to topic Reply with quote

what would cause a c# windows timer to slow down?

i'm using a timer to simply keep track of the time on one of my apps, and quite often, but not always, the timer will "lag". as in the intervals are much farther apart then they are supposed to be. the "lag" can be different each time.

could it be that i just have a slow computer(256mb ram)? or should it not matter?

it's important that this timer is at the right speed. any suggestions?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Aug 26, 2008 10:43 pm    Post subject: Reply to topic Reply with quote

What "timers" are you using? Most timing systems guarantee that they won't be triggered before the time out, but make no guarantee when it will have time to come back. So if another process is running, you have to wait until that process (and any others scheduled ahead of you) finish.

I bet if you set your programmer to "Above Normal" processing priority, the timers will be closer to their timeout period, as it will jump ahead in the CPU scheduler.
Back to top
View users profile Send private message Add User to Ignore List Send email
Snrrrub
Novice


Joined: May 29 2008
Posts: 37
Offline

PostPosted: Tue Aug 26, 2008 11:11 pm    Post subject: Reply to topic Reply with quote

How much is the timer drift and what's the timing interval? If the interval is close to the timer precision (which must be documented somewhere), you're likely to see significant drift. You might be able to access the multimedia timers for higher precision events but I'm not sure how one would go about doing that in C#.

Related to what MGB said, the OS time slice impacts the precision of your timer callback. IIRC, the NT kernel series has a time slice of 15ms but it's possible in newer kernels to decreasing the time slice to 1ms using a Win32 API call (which I can't remember off the top of my head) or by running Windows Media Player in the background.

Your RAM should have virtually no impact on timer precision.

-Snrrrub
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Wed Aug 27, 2008 1:08 am    Post subject: Reply to topic Reply with quote

Snrrrub wrote:
You might be able to access the multimedia timers for higher precision events but I'm not sure how one would go about doing that in C#.

High Precision Interval Timer in C#. Give that a try.
Back to top
View users profile Send private message Add User to Ignore List Send email
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Wed Aug 27, 2008 4:10 pm    Post subject: Reply to topic Reply with quote

I'm using the one built into the .net framework.

the interval is pretty low, at 1/100 of a second(maintimer.Interval = 10 to be exact).


i'll try the high precision timer first. if that doesn't work, i'll try setting it to 1/10 of a second.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Wed Aug 27, 2008 8:55 pm    Post subject: Reply to topic Reply with quote

I just tested it again and it worked fine. The the only difference between this test and the one previous was that the one previous was running just-in-time debugging, and probably other things in it's first run (is still in intermediate language?).

Could that be the cause?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 657 page(s) served in previous 5 minutes.

phpBB Created this page in 0.404954 seconds : 31 queries executed (94.2%): GZIP compression disabled