Asp.net background Processing Technology

Source: Internet
Author: User

In Asp.net web development, we often encounter the following problem: Slow user operation response.

This situation may occur because user operations are time-consuming operations. . Net program is designed in the background when the user submits the operation. After the processing is complete, the operation result is returned to the user. In a smaller system, this design is simple and easy, and the performance does not have much problems. However, in a larger system, this design will give users a poor operation experience, this affects users' impression of the system.

In the system I previously implemented, there are generally two ways to deal with this situation: 1. record user operations directly to the backend database for regular scanning by the background program. Ii. Use Asp.net's timed processing method to process the data directly on the Web server layer.

There is no big difference between the two methods. The first method mainly requires a background program to complete the scanning.

Here I will briefly introduce the second method.

Its core processing is system. Threading. Timer. This scheduled class can be used to periodically execute user submission operations in the background,

Its Usage:

System. Threading. timercallback T = new system. Threading. timercallback (your solution );

System. Threading. Timer T = new system. Threading. Timer (T, null, 1000,5000 );

This section indicates that the specified proxy is called every five seconds after 1 second of startup.

In specific implementation, I define three classes.

1. bkexecitem is used to save the user's submitted operations. It can also be serialized to the disk to avoid the loss of key background tasks.

2. bkexec is used for execution. It calls the method specified in bkexecitem through reflection. In addition, it also maintains

The first-out queue <bkexecitem> records all background processing items.

3. bkmanager initializes the timer and configures the module parameters.

Well, we will summarize it here for the time being. Next time, I will post the code for your reference.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.