|
||||||
| C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||||
|
The Timer does not work in this way. What you do is set the timer's Interval property to 4000 (specified in milliseconds):
Code:
System.Timers.Timer timer2 = new System.Timers.Timer(); timer2.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Tick); timer2.Interval = 4000; timer2.Start(); Xav |
|
|||||
|
this is a little better way to write it yes...but not really helping with my problem. I need to elapse time but carry the variable values over from the method which calls the timer to the code after the timer. I could just keep the same method going but I don't know how to make the timer pause the other method. The other option is to start another method in the tick handler with the next code to execute. I don't know how to pass the values into the tick handler to use as parameters for the next method call.
Last edited by gaylo565; 05-02-2008 at 01:00 AM. |
|
|||||
|
I don't see any variables to carry over. What are they?
You can declare any variable as "private", as in: Code:
private string myText = "This is a global, or module-level variable."; Does this answer your problem? |
|
|||||
|
That's OK. I don't think the Thread.Sleep() method is the best choice, though - this method suspends the thread on which the program is run on. Therefore, during the 4 seconds the window completely freezes up, so the user cannot access it. A timer executes the time on a separate thread, so the user interface does not freeze up.
|
|
|||||
|
It seems to work for the purpose...I could always start a new thread and do a sleep on the secondary thread as well. I was just having to many problems with the timer. I could get it to pause but not before it re-enabled my buttons. Im sure there is a way to make it work for my app but i'm tired of trying and need to get this done. Once again thanks for your help...im sure ill come up with another q for ya soon if not today.
|
|
|||||
|
You're welcome - when you want to learn how to use timers properly, you can always do it in your own time. Good luck with your program!
|
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows Shortcut List - Saves Time | 2stamlers | The Lounge | 6 | 04-10-2008 06:58 AM |
| A simple timer | travy92 | VB Tutorials | 1 | 02-18-2008 09:08 AM |
| Minimum time to make live a Website in Internet | eric | Search Engine Optimization | 3 | 11-25-2007 01:09 PM |
| Minimum time to make live a Website in Internet | Jaser | Search Engine Optimization | 2 | 11-08-2007 11:44 PM |
| Odd Timestamp | dirkfirst | C# Programming | 10 | 12-08-2006 04:40 PM |