Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] C# Timers

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jan 19, 2008 10:08 am    Post subject: [Help] C# Timers Reply with quote

Code:

Timer t1 = new Timer();
t1.Enabled = true;
t1.Interval = 1000; //if i'm not making a mistake it suppose to be 10 seconds
t1.Start();


so i'v created a timer and now i wanna print it on console screen and watch him decreased any second. how do i do that?!? i tried to do
Code:

Console.WriteLine(t1);

but all i get from that is System.Timers ... bla bla... interval = 1000;
:S :S

_________________
Stylo
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Jan 19, 2008 10:46 am    Post subject: Reply with quote

In your initalization of the timer, do this:

Code:

timer1.Tick += new new EventHandler (t_tick);


then (if you don't let VS do this for you), create a new method:

Code:

private static void t_tick(object sender, TimerEventArgs e)
{
      //do whatever you want it to do when each interval comes up
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sat Jan 19, 2008 11:07 am    Post subject: Reply with quote

Code:
 private void t1_Tick(object sender, EventArgs e)
        {
              //specify what you would like to do at each tick!
        }

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Jan 19, 2008 11:09 am    Post subject: Reply with quote

Naablet wrote:
Code:
 private void t1_Tick(object sender, EventArgs e)
        {
              //specify what you would like to do at each tick!
        }


That won't work if the user hasn't given the timer another event handler.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sat Jan 19, 2008 11:13 am    Post subject: Reply with quote

samuri25404 wrote:
Naablet wrote:
Code:
 private void t1_Tick(object sender, EventArgs e)
        {
              //specify what you would like to do at each tick!
        }


That won't work if the user hasn't given the timer another event handler.

Oh i see.

so with this code you can add a handler while running the program?
Code:
timer1.Tick += new new EventHandler (t_tick);

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jan 19, 2008 1:47 pm    Post subject: Reply with quote

i'm getting error with the word TimerEventArgs.
it says that there's no such thing :s
btw another question.. how do i convert millisecond into a second?

_________________
Stylo


Last edited by Stylo on Sat Jan 19, 2008 2:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Jan 19, 2008 2:18 pm    Post subject: Reply with quote

Ok, then just do "EventArgs"
_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sat Jan 19, 2008 2:22 pm    Post subject: Reply with quote

thx the timer is working but how do i convert millisecond into a seconds?
_________________
Stylo
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sat Jan 19, 2008 2:56 pm    Post subject: Reply with quote

If you mean by watching it decrease in the console then whenever you print it to console print it / 1000
_________________
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sat Jan 19, 2008 3:04 pm    Post subject: Reply with quote

Why don't u just manually add the event!
-.-
Like i do.
Propeties --> events

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Jan 19, 2008 3:30 pm    Post subject: Reply with quote

Because it's a Console Application.
_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Sat Jan 19, 2008 3:42 pm    Post subject: Reply with quote

samuri25404 wrote:
Because it's a Console Application.


Oh.
That's explains it.

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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 cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites