System.Timers.Timer question on how to stop this timer

I have a webpage with two buttons:

"Start timer" and "Stop timer"

When I click the "Start timer" the timer object is started, with the start method

oTimer.Start()

This works great!

When I click the "Stop timer", the timer keeps running.

oTimer.Stop()

What goes wrong?


Johan Theunissen
MCPD, MCSE, MCTS BizTalk 2006

==============================

Please mark the most helpful reply/replies as "Answer".
0
JohanNL
6/4/2007 9:36:46 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

3 Replies
563 Views

Similar Articles

[PageSpeed] 7

Is oTimer a page-level instance? If so, you will be calling the Stop() method on a different instance.

Maybe you can store the timer instance in the session? (not sure if this works)

 

---
Martin 


Please mark this post as Answer if it was helpful.

-- Martin
0
mbischoff
6/4/2007 9:45:43 AM

Hi,

First disable the timer then stop it.

oTimer.Enabled=false;

oTimer.Stop();


Mehedi Hasan


Mark as answer if the post meets your requirement!
0
M
6/4/2007 10:07:38 AM

Protected Sub btnStopPrototype_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStopPrototype.Click
oTimer.Enabled =
False
oTimer.Stop()
End Sub

The code above does not work.

When I stop debugging the page, the timer still keeps running.
When I start debug again, the timer automatically stops.

What to do?

 


Johan Theunissen
MCPD, MCSE, MCTS BizTalk 2006

==============================

Please mark the most helpful reply/replies as "Answer".
0
JohanNL
6/6/2007 7:17:49 AM
Reply:

Similar Artilces:

I cannot find Timer of System.Timers.Timer
I want to create a Windows Service by VB using VS 2005. However I cannot find Timer type System.Timers.Timer in Toolbox. I must as follow. However I cannot call function that handles Timer1.elapse Based on my understanding that because the system does not understand Timer1. Can anybody help me please? Thank you very much. -----------------------------------------------------------------------------------------------------    Dim Timer1 As System.Timers.Timer     Protected Overrides Sub OnStart(ByVal args() As String)      &n...

new thread started bt System.Timers.Timer?
HI, i have used a Timer in Application_Start() : System.Timers.Timer aTimer = new System.Timers.Timer(); aTimer.Elapsed+=new System.Timers.ElapsedEventHandler(do_functions); aTimer.Interval=30000; aTimer.Enabled=true; i am running the application with an impersonation to a specific user. the problem is that when do_functions is called by the Timer, the impersonation is gone and Environment.UserName is "NETWORK SERVICE". i need to be able to control the identity of this so that do_functions has the right permissions. Any ideas? TIA ...

System.Timers.Timer issue
Hi- I have created a test program, where on click of a button I want to start three threads, thread1 at interval of 2 mins thread2 at interval of 3 mins and thead3 at interval of 5 mins. When I click the button all these threads are created successfully and all three log the entry in my log file indicating that they are being called. But the next time onwards, I see only the last thread in the function being fired at the specified interval of 5 mins. Wondering what's going on with the first two ones, they were called only once and never again. Protected Sub btnStartTimer_Cl...

I can't get the Timer in 'System.Timers' to work.
Why does my Heartbeat not work?Is it something to do with methods needing to be static?  Even when I set AppSettings["Heartbeat"] = "1" it still does not work.//--------------------------------------------------------------------// Global.cs (part of)//--------------------------------------------------------------------    protected void Application_Start(object sender, EventArgs e)    {        string strConStringName = (string)ConfigurationManager.AppSettings["connectionString"];   ...

System.Timers.Timer does not work properly
Hi; I am going to generate a scheduled task on my ASP.NET web application using System.Timers.Timer class. The timer would start on Application_Start event and do the job for example every 10 minutes, periodically. Everything is OK, but the timer works for 3 times (More or less) and then be killed. I expect such timer must be kept running 24 hours a day, 7 days a week. Please help me if you know something useful. Regards, M.Sadegh Samiei Well, ASP.Net is not a "service", the Application of the web app will be "terminated" when it's idle for a time (after the last us...

System.Timers.Timer culture
Hello,The setup used is a windows 2003 server r2 and .NET 2.0 and a similiar setup. The differance is the language they are installed on. Swedish and English (UK) I have a System.Timers.Timer object, which is created during Application_Start to preform actions every tick.On both servers. the machine.config, web.config (both global and website specific) the globalization config is as follows:<globalization culture="sv-SE" uiCulture="sv-SE"/> All regional settings on the server that we can find is set to Swedish and Sweden.  Before the Timer is created ...

Handling exceptions in System.Timers.Timer
I have a System.Timers.Timer in my ASP.Net application that executes some code every 15. seconds. The user should be notified if something goes wrong during execution. I have inserted a try-catch-block in my elapsed-method, which catches the exceptions, but how do I throw the exception up ? I have tried with "throw myexception", but the exception is not caught anywhere even though I have placed try-catch-blocks around all method-calls. Where / how do I catch the exception ? TIA Thomas Dolberg The timer does a fire and forget, it fires your event, but it doesn't wait to see w...

Timeout for the Timer? (I.e Stop the timer)
Is there a timeout that can be set for the timer?   I.e: Have a timeout on 60000ms but I dont want it to execute more than four times if the user doesn't update the page. I have a login control that times out after 5min of inactivity and the timer control is in a updatepanel and after 5min i get an error as the user has been timed out. d-ToxicShock Sorry for the first post :(   You can keep a count variable that gets incremented each time the timer event fires.  Then when that variable =4, you can set the enabled property of the timer to false.  This ...

System.Timers.Timer Class
WebForm programming can be very challenge. You have to think server side, then you have to think client side. Anyway, I need a tutorial, code example or something about server side class System.Timers.TimerI scouted around but haven't come up with a gooc one yet. Thanks, ngungo What do you need the Timer for?RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-97 78 79Mail: info@seventhday.se-------------------------------- Hi adec,I am converting a WinForm to its counterpart WebForm app. The application involves arou...

"System.Timers.Timer" Help!
Hi I am trying to get a 1 Second Timer to work without much success. Can someone please Help ! Development Environment: Microsoft Visual Studio VBasic.Net Active Server Page Web Form Operating System: Windows XP Here is what I have done: 1) Drag Timer component from Toolbox to Design Page 2) Visual Studio Created : Private Sub InitializeComponent() Me.Timer1 = New System.Timers.Timer CType(Me.Timer1, System.ComponentModel.ISupportInitialize).BeginInit() ' 'Timer1 ' Me.Timer1.Enabled = True Me.Timer1.Interval = 1000 CType(Me.Tim...

i am doing a project on online exam system. i am having the problem with countdown timer values i.e. timer is strting from the begining wen i am clicking the next button for next question
here is my code: // JScript File var mins var secs;function cd() { mins = 1 * m("10"); // change minutes here secs = 0 + s(":01"); // change seconds here (always add an additional second to your total) redo(); }function m(obj) { for(var i = 0; i < obj.length; i++) {if(obj.substring(i, i + 1) == ":")break; } return(obj.substring(0, i)); }function s(obj) { for(var i = 0; i < obj.length; i++) {if(obj.substring(i, i + 1) == ":")break; } return(obj.substring(i + 1, obj.length)); }function dis(mins,secs) { var disp;if(mins <= ...

[ASK] Problem with System.Timers.Timer in Global.asax
I have a static timer declared in global.asax and add a new handler to execute every certain period of time.  The thing is it runs on visual studio but once I placed it on IIS it does not even run once.  Any clue? IIS won't start your website when you just put it there. It should be started on the first request made on the web. However when no requests are made for a certain period of time the website will be unloaded and your timer won't work again. If you really need a way how to execute something every x hours/minutes then go for windows services. Check these tutorial...

problem with System.Timers.Timer class and Global.asax
Hi, I'm trying to run a function periodically (every 5 minutes). The timer function works and triggers the function but the function returns a null exception error. However, if the function is called without the timer, it works. Ideas? Here is the code from the Global.asax file: <%@ Application Language="C#" %><%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Timers" %> <script RunAt="server"> void Application_Start(object sender, EventArgs e) { Timer myTimer = new Timer(); myTimer.Interval = 5000;...

Timer() & Timer event
Am using Powerbuilder 6.5.1 & Oracle 8.0.4 on WINNT. Have a requirement to refresh(reretrieve 8 datawindows in one window, at different intervals. One dw might need to be refreshed in 5 minutes, another in 2 minutes, and still another in 7 minutes, etc. If I place a timer(300) right after the initial retrieve in the Open event of the window for dw_1, and in the Timer event of the window code, dw_1.Retrieve, then, I would expect that in 5 minutes, that dw would be refreshed. But, I have six other windows that need to be refreshed at different times. How would I code for this in t...

Web resources about - System.Timers.Timer question on how to stop this timer - asp.net.getting-started

German question - Wikipedia, the free encyclopedia
"Kleindeutschland" redirects here. For the neighborhood in New York City, see Little Germany, Manhattan . 1820 map of Central Europe showing ...

Facebook’s Helen Crossley on the 3 Big Mobile-Commerce Questions
Mobile grabbed hold of the holiday shopping season in 2014, and there is no reason to believe that trend won’t continue this year. Helen Crossley ...

Question Of The Day: First-ever car ride?
Filed under: Automotive History The first time you were ever in a motor vehicle, what was it? Continue reading Question Of The Day: First-ever ...

‘The Walking Dead’ episode 7: A heart-pounding answer to ‘the Glenn question’
The seventh episode of The Walking Dead season 6 aired last night, and it had an interesting overall theme: people need saving. Unexpectedly, ...

Housing Rebound Didn't Lift Economy as Much as Economists Expected: Why?; Six Questions for Zandi
Home prices are nearly back to where they were before the crash. In some places, home prices are above where they were at the peak of the national ...

Real question: did Brad Pitt wear a ’90s wiglet at ‘The Big Short’ premiere?
Brad Pitt could potentially have a film at the Oscars this year. NO, not By the Sea . His real Oscar-bait film this year is The Big Short , which ...

Want a job at Apple? Here are 10 of the toughest interview questions
We alternately praise and criticize the folks at Apple depending on whether they just created the iPhone or Apple Maps, but there’s no doubting ...

Trump questions Hillary's 'stamina,' apparently unaware of her marathon Benghazi hearing
Donald Trump will find a new criticism of Hillary Clinton soon because his latest one is downright ludicrous. In an appearance on ABC’s “This ...

Lisa Vanderpump Is the Latest 'RHOBH' Star to Question Yolanda Foster's Lyme Disease
Lisa Vanderpump Is the Latest 'RHOBH' Star to Question Yolanda Foster's Lyme Disease

What's The Right Way To Ask Audiences Questions?
The key to asking questions of an audience is authenticity.

Resources last updated: 11/27/2015 4:01:34 AM