473,387 Members | 1,669 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,387 software developers and data experts.

timer ability in serverside c#, triggered from aspx?

There's common use of setTimeout() in javascript to cause a delay on the
client of an asp.net app.
I'm experimenting w/ a serverside delay. Ie, maybe there's a backend
process that I want to occur 10 seconds after the user hits the button on
the webpage -- not immediatly. Perhaps 1 codebehind function to call
another codebehind function after a 10 second delay. Any ideas if this can
be done?
Nov 16 '05 #1
5 1712
it seems System.Threading.Thread.Speep(10000); would cause a 10 sec delay.
not sure if its the best way to do it but it seems to work
Nov 16 '05 #2
Jason,

Why you would want to do that is beyond me (then again, what do I
know?).

The only way I can think of doing this is to call Sleep on the current
thread. You would have to put the thread on hold somehow (if you exit the
processing of the thread, then the response is sent back). The best way to
do this would be through a call to Sleep.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jason Shohet" <__******@yahoo.com> wrote in message
news:er*************@TK2MSFTNGP11.phx.gbl...
There's common use of setTimeout() in javascript to cause a delay on the
client of an asp.net app.
I'm experimenting w/ a serverside delay. Ie, maybe there's a backend
process that I want to occur 10 seconds after the user hits the button on
the webpage -- not immediatly. Perhaps 1 codebehind function to call
another codebehind function after a 10 second delay. Any ideas if this
can be done?

Nov 16 '05 #3
Jason Shohet wrote:
There's common use of setTimeout() in javascript to cause a delay on
the client of an asp.net app.
I'm experimenting w/ a serverside delay. Ie, maybe there's a backend
process that I want to occur 10 seconds after the user hits the
button on the webpage -- not immediatly. Perhaps 1 codebehind
function to call another codebehind function after a 10 second delay.
Any ideas if this can be done?


Maybe you can use the ThreadPool class for this.
One thing you *can't* do is create a Timer in the aspx to execute
a function "in a little while", because that instance of the aspx-class
will cease to exist when the request is done.
You might be ably to use "Sleep" (as other posters replied), but that has
the disadvantage that the page "hangs" during this time and request-timeouts
may occur.

Hans Kesting
Nov 16 '05 #4
this is curiosity only here, but lets say you do:

Thread.Sleep(some #);
some code to write to a text file;

Lets say the session expires before the amount of time. Will the code that
writes to a text file execute. IOTW, does the session expiring also kill
the thread.
Nov 16 '05 #5
Jason Shohet wrote:
this is curiosity only here, but lets say you do:

Thread.Sleep(some #);
some code to write to a text file;

Lets say the session expires before the amount of time. Will the
code that writes to a text file execute. IOTW, does the session
expiring also kill the thread.


I don't know, never needed to find out.
The user requesting the original page would probably see a
"hanging site" as the page never finishes processing/loading.
Maybe a Response.Flush() can send the page contents (so far)
to the browser, but that browser will still wait for "the rest".

I don't think it is generally a good idea to use Sleep in
a website.

Hans Kesting
Nov 16 '05 #6

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

Similar topics

3
by: Andy | last post by:
Hello. I want to use System.Threading.Timer to control when my windows form is invalidated. I want it to update at 60 frames per second. But, if I set the Interval of my timer to anything less than...
5
by: Dhilip Kumar | last post by:
Hi all, I have developed a windows service using the windows service project template in VS.NET. I have used three controls in the service, a timer, performance counter and a message queue...
6
by: Antti Laakso | last post by:
Hi i have function like above Public Sub halytystutkinta() Dim ds As New DataSet ds = dl2.HaeHalytys() Dim onkohal As Int16 onkohal = ds.Tables(0).Rows(0).Item("onkohalytys") halid =...
19
by: adi | last post by:
Hi I need the following: at particular times of day, I want to make some processing. System.Windoes.Timer doesn't help much, because it exposes the Interval property. Instead, I need to tell...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.