Solved

.Net timer

Posted on 2013-06-11
3
366 Views
Last Modified: 2013-06-11
I have a timer on my page that is disabled and the interval on the timer is 1000

I assume that's milliseconds?

On a click event I want to

Timer1.Enabled = True
Timer1.start()

run for 15 seconds

Timer1.Stop
Timer1.Enabled = False
0
Comment
Question by:lrbrister
3 Comments
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
add integer field in your class and set it to 0.
on the timer elapse event handler add 1 to the integer field each time.
also check if the field equals 15, if yes then stop the timer and set .Enabled = false, and reset the integer field to 0 again.
0
 
LVL 1

Accepted Solution

by:
OSUK earned 500 total points
Comment Utility
My suggestion would be...

In the Click event put the code
Timer1.Interval = 15000  'yes the time is in milliseconds
Timer1.Start

Open in new window


In the Timer1_Tick event..
Timer1.stop
'Add whatever code you wish to process

Open in new window


If you can include a bit more detail of what you are trying to achieve with the timer i could provide more detail.
0
 

Author Closing Comment

by:lrbrister
Comment Utility
THis had example code and  got me going.
Thanks...it's working

I have this
    Protected Sub lnkFrustrated_Click(sender As Object, e As EventArgs) Handles lnkFrustrated.Click
        tmrFrustrated.Interval = "19000"
        imgFrustrated.Visible = True
        tmrFrustrated.Enabled = True

    End Sub

    Private Sub tmrFrustrated_Tick(sender As Object, e As System.EventArgs) Handles tmrFrustrated.Tick
        tmrFrustrated.Enabled = False
        imgFrustrated.Visible = False
        lblImage.Text = "Have a nice day!"
    End Sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Limiting string to two deciamls 18 30
Hide Tab Page 3 18
C# DataGridView_RowsAdded event not firing 1 36
VB.Net - For Loop Error 5 23
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now