473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Timer Execution

Hi,

Is there a way to execute a function after 1 minute on server-side once a
web form is rendered? Can you please show me some code to illustrate this?

Thanks,

~yamazed
Nov 17 '05 #1
6 1534
Salam

Work with "Timer" on the server side and Excute the function when the timer
complete 1 Min, and then reset it

--
ALI RAZA SHAIKH
MCAD.net

www.programmersparadise.cjb.net
alirazashaikh.blogspot.com
"Yama" <ya**@yamabiz.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,

Is there a way to execute a function after 1 minute on server-side once a
web form is rendered? Can you please show me some code to illustrate this?

Thanks,

~yamazed

Nov 17 '05 #2
In your page class, create a method that calls
Thread.Sleep(TimeSpan.FromMinutes(1)) and then executes some code. Create a
new thread to call that method. It will cause the thread in which the method
is running to sleep, not the main thread.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Yama" <ya**@yamabiz.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,

Is there a way to execute a function after 1 minute on server-side once a
web form is rendered? Can you please show me some code to illustrate this?

Thanks,

~yamazed

Nov 17 '05 #3
BTW, I should mention that using a timer would be a waste. Timers are only
useful if you want to repeat something at intervals.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...
In your page class, create a method that calls
Thread.Sleep(TimeSpan.FromMinutes(1)) and then executes some code. Create
a new thread to call that method. It will cause the thread in which the
method is running to sleep, not the main thread.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Yama" <ya**@yamabiz.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,

Is there a way to execute a function after 1 minute on server-side once a
web form is rendered? Can you please show me some code to illustrate
this?

Thanks,

~yamazed


Nov 17 '05 #4
Kevin,

Let's say I have my page default.aspx that has render to client browser what
you are telling me is that I could use the Thread.Sleep static method. But
what event shall I tie a delegate to to fire this method?

Can you drop a quick code illustration?

Thanks,

~yamazed
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...
In your page class, create a method that calls
Thread.Sleep(TimeSpan.FromMinutes(1)) and then executes some code. Create
a new thread to call that method. It will cause the thread in which the
method is running to sleep, not the main thread.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Yama" <ya**@yamabiz.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,

Is there a way to execute a function after 1 minute on server-side once a
web form is rendered? Can you please show me some code to illustrate
this?

Thanks,

~yamazed


Nov 17 '05 #5
How? In what page event?
"ALI RAZA" <al*************@yahoo.com> wrote in message
news:eN**************@TK2MSFTNGP15.phx.gbl...
Salam

Work with "Timer" on the server side and Excute the function when the
timer complete 1 Min, and then reset it

--
ALI RAZA SHAIKH
MCAD.net

www.programmersparadise.cjb.net
alirazashaikh.blogspot.com
"Yama" <ya**@yamabiz.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,

Is there a way to execute a function after 1 minute on server-side once a
web form is rendered? Can you please show me some code to illustrate
this?

Thanks,

~yamazed


Nov 17 '05 #6
As you want to run it as soon before the page is sent to the client, create
an event handler for the PreRender event, and call your method that executes
the code from that event handler. Example:

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.PreRender +=new EventHandler(Page1_PreRender);
}

private void Page1_PreRender(object sender, EventArgs e)
{
Thread myThread = new Thread(new ThreadStart(this.WaitAMinute));
myThread.Start();
}

private void WaitAMinute()
{
Thread.Sleep(TimeSpan.FromMinutes(1));
// Do Something
}

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"Yama" <ya**@yamabiz.com> wrote in message
news:eA**************@tk2msftngp13.phx.gbl...
Kevin,

Let's say I have my page default.aspx that has render to client browser
what you are telling me is that I could use the Thread.Sleep static
method. But what event shall I tie a delegate to to fire this method?

Can you drop a quick code illustration?

Thanks,

~yamazed
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OE**************@TK2MSFTNGP14.phx.gbl...
In your page class, create a method that calls
Thread.Sleep(TimeSpan.FromMinutes(1)) and then executes some code. Create
a new thread to call that method. It will cause the thread in which the
method is running to sleep, not the main thread.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Yama" <ya**@yamabiz.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,

Is there a way to execute a function after 1 minute on server-side once
a web form is rendered? Can you please show me some code to illustrate
this?

Thanks,

~yamazed



Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
Hello all, I know why the following doesn't work ... I can't figure out how to make it work like I want it to. Basically, I only want the loop computing fibonacci numbers to run for approx 5...
2
by: laurenq uantrell | last post by:
I have been using the following function to test the speed of various functions, however, quite often the return value is zero. I'm hoping someone can help improve on this. Function TimeIt() As...
8
by: theinvisibleGhost | last post by:
I think I've found a bug in the timer control. I've got a class which uses a timer control. It imports it from System.Windows.Forms This timer ticks once a second, and then updates a label...
6
by: whtinkm | last post by:
Hi, All Recently, my project need some code like following: using System; using System.Threading; namespace MyTimerTest { class Class1 {
8
by: Jim Hammond | last post by:
The following code tries to excute a function 10 seconds after Page_Load by using a Timer, but the callback never gets called. private void Page_Load(object sender, System.EventArgs e) { ...
8
by: Jason Shohet | last post by:
Lets say I want a button to execute 10 seconds after I press it, not immediately. Any ideas how to cause that, in a code-behind. IMO its only server side code, I don't think javascript needs to...
19
by: UG | last post by:
I just wanted to know whether any timer facility exists in C, as it is not mentioned in K&R 2, or in the ISO Draft. By timer function i mean that when we use standard input function like scanf() or...
0
by: steveyjg | last post by:
I'm trying to call a function that will pause execution for 30 seconds and have a counter timer counting to 30 seconds during this pause. When the counter hits 30 execution of the program will...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
0
by: Aads | last post by:
Hi there, I've two forms namely FormA & FormB whose constructors initialize some ActiveX controls (to display some default charts) & does some init tasks which are time consuming as shown in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.