Timers on a console application

How to stoop a console application using timers

Page 1 of 1

4 Replies - 14261 Views - Last Post: 08 January 2009 - 06:08 PM Rate Topic: -----

#1 p62483t  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-January 09

Timers on a console application

Posted 08 January 2009 - 06:32 AM

:) HI, I am new in .net but I am working on a console application and all I want to do is stop the consolo application if it is idle for more that 3 minutes. I did this on a VB6 using the timer but in .net i can't. Please help....
Is This A Good Question/Topic? 0
  • +

Replies To: Timers on a console application

#2 Zuelin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-December 08

Re: Timers on a console application

Posted 08 January 2009 - 02:25 PM

View Postp62483t, on 8 Jan, 2009 - 05:32 AM, said:

:) HI, I am new in .net but I am working on a console application and all I want to do is stop the consolo application if it is idle for more that 3 minutes. I did this on a VB6 using the timer but in .net i can't. Please help....


I'm still somewhat new too, but if you do use the Timer Control in VB.Net set it to 180000 (1000 for each second, 180 seconds in 3 minutes). This would let the application sit on the screen for 3 minutes and then it would disappear.

Again, not sure if that will help any but that's just my thought.

------
Zuelin
Was This Post Helpful? 0
  • +
  • -

#3 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Timers on a console application

Posted 08 January 2009 - 03:25 PM

You can't use the standard Windows Forms Timer control in console applications.

Take a look at the System.Timers namespace. If you declare this namespace in your console application, you can customize the Timer control the same way you do it in a WinForms application (set the interval, enable/disable it etc.). You will just have to manually declare the Timer class and add a Tick event handler for it.
Was This Post Helpful? 0
  • +
  • -

#4 dbasnett  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 109
  • View blog
  • Posts: 603
  • Joined: 01-October 08

Re: Timers on a console application

Posted 08 January 2009 - 04:08 PM

look at StopWatch
Was This Post Helpful? 0
  • +
  • -

#5 nightscream  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 237
  • Joined: 04-December 08

Re: Timers on a console application

Posted 08 January 2009 - 06:08 PM

this should work
System.Threading.Thread.Sleep(180000)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1