According to Global. in the asax code, we set a timer to execute the fresher () process every 10 seconds. In the fresher () process, we actually just re-write an application ("timestamp ") new value. In other words, the value of application ("timestamp") should be updated every 10 seconds.
Is that true? Refresh test. aspx repeatedly to observe the value of application ("timestamp"). It is indeed found that this value changes once every 10 seconds, and remains unchanged at other times. It is consistent with our expectation.
Meaning:
By introducing the timer, We can flexibly use the timer in the ASP. NET Global Program (Application) to perform some scheduled operations, for example: Community/In the forum system, the online user list is updated every 5 minutes, the user experience is updated every 1 hour, or key data is backed up every other day. This idea should be very attractive.
Discussion:
Q: Can I use a timer anywhere in ASP. NET code?
A: I have not tested how to insert a timer in common *. aspx. However, from the characteristics of the B/S program, it is not a good choice even if the timer is inserted in *. aspx. For B/S programs, the request sent from the server to the client is an event. During the event processing, the server must respond quickly to generate HTML code for the client, and end the process. If *. aspx uses a timer (if allowed), the first is not necessary, and the second is easy to make the system too many timers (because every time *. aspx execution may insert a new timer) to paralyze the system.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service