0

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.......

2
  • Why do want this? What are you trying to achieve? Commented Jul 18, 2012 at 10:42
  • Timer is related to threads and in server side programming you are not supposed to use threads. You have to make it to work alternatively for whatever you want to do. First you see whether what you need to achieve is possible thru different event trigger or can do same using Javascript ajax call or some other means. Commented Jul 18, 2012 at 10:53

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

since you only need it once

Comments

0

The simplest is:

Thread.Sleep(<mlsec>)

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.