Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
i want to use timer in the login button i want the user to wait for 1 minute befor he enter the main page how can i use it???
Posted
Comments
Sergey Alexandrovich Kryukov 15-Mar-12 2:40am    
This it pretty much straightforward. What's the problem. Do you use Forms? It would make big difference.
Tag your UI library and/or type of application -- it does matter in this case.
--SA
dr.dream 15-Mar-12 2:50am    
yas i mean the form .i have login form and when the user click on (sign in) button iwant him to wait for 1 minute befor the main page form

This is one of the rare cases when the timer System.Windows.Forms.Timer is adequate:
http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx[^].

Don't forget to setup timer's Interval = 1000; P.S.Vijay did not show it.

I need to explain. This timer is the worst but simplest to the use with Forms. Unlike two other timer classes, it has very bad accuracy, not acceptable if you need the sense of something periodic, forget about more serious requirements. But for your purpose it's good enough.

—SA
 
Share this answer
 
Try with this


VB
Dim dt As Date

   Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

       dt = DateTime.Now()
       dt = DateAdd(DateInterval.Minute, 1, DateTime.Now())

       Timer1.Enabled = True

   End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If DateTime.Now() > dt Then
            Form2.Show()
            Timer1.Enabled = False
            Exit Sub
        End If
    End Sub
 
Share this answer
 
Use this..

Thread.Sleep(20000);
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900