Home All Groups Group Topic Archive Search About
Author
16 Apr 2005 12:28 AM
John Devlon
Hi everyone....

I'm trying to make something work...

When I launch a new form, the application has to quit after a few seconds...

I searched the net for some hours and I can't find any usefull code ...
I noticed there are several timers in .net...
Which one do I use ?

Thanx

John

Author
16 Apr 2005 5:17 AM
Adam Goossens
Hi,

If you're using Windows Forms, use a System.Windows.Forms.Timer. Put the
timer on your form and attach to the Timer.Tick event. When the event
fires, call Application.Quit().

You can use System.Threading.Timer if you want, but this uses Windows
resources. The System.Timers.Timer class is more for server-based timers
that need better accuracy and ability to move between threads.

Regards,
-Adam.

John Devlon wrote:
Show quoteHide quote
> Hi everyone....
>
> I'm trying to make something work...
>
> When I launch a new form, the application has to quit after a few seconds...
>
> I searched the net for some hours and I can't find any usefull code ...
> I noticed there are several timers in .net...
> Which one do I use ?
>
> Thanx
>
> John
>
>
Author
16 Apr 2005 11:14 AM
John Devlon
Thanx Adam, It works great....

Below the code for other people who need it ...


Private Sub quit_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        Timer.Start()
End Sub


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer.Tick
       Application.Exit()
End Sub


John






Show quoteHide quote
"Adam Goossens" <adam.gooss***@gmail.com> schreef in bericht
news:uNMeAOkQFHA.2136@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> If you're using Windows Forms, use a System.Windows.Forms.Timer. Put the
> timer on your form and attach to the Timer.Tick event. When the event
> fires, call Application.Quit().
>
> You can use System.Threading.Timer if you want, but this uses Windows
> resources. The System.Timers.Timer class is more for server-based timers
> that need better accuracy and ability to move between threads.
>
> Regards,
> -Adam.
>
> John Devlon wrote:
>> Hi everyone....
>>
>> I'm trying to make something work...
>>
>> When I launch a new form, the application has to quit after a few
>> seconds...
>>
>> I searched the net for some hours and I can't find any usefull code ...
>> I noticed there are several timers in .net...
>> Which one do I use ?
>>
>> Thanx
>>
>> John