user1530976
user1530976

Reputation: 3

Create a timer in asp.net Server side

I have a asp.net web application , in that application I will call a function once that function s called , it has to wait for some time interval then execution should take place how to do that.......

Upvotes: 0

Views: 1514

Answers (3)

Kyle Trauberman
Kyle Trauberman

Reputation: 25684

Sleeping or delaying the thread in asp.net is not recommended. If you need to to retrieve some data after a specific period of time, make an ajax call through javascript after a period of time.

If you want to perform some action (such as sending an email) after some time, create a service or a console application that you can run on a timer, create some sort of persistent queue, and have said service process the items in the queue.

This will allow your app to remain quick and responsive while still performing the actions you require.

Upvotes: 1

Johnny_D
Johnny_D

Reputation: 4652

The simplest is:

Thread.Sleep(<mlsec>)

The coolest is using some scheduler, e.g. Quartz.net.

Upvotes: 0

JohnnBlade
JohnnBlade

Reputation: 4327

you can do it like this System.Threading.Thread.Sleep(5000); 5000 = 5 seconds

since you only need it once

Upvotes: 0

Related Questions