CN104516745A - Method and system for running timing task - Google Patents
Method and system for running timing task Download PDFInfo
- Publication number
- CN104516745A CN104516745A CN201310451795.3A CN201310451795A CN104516745A CN 104516745 A CN104516745 A CN 104516745A CN 201310451795 A CN201310451795 A CN 201310451795A CN 104516745 A CN104516745 A CN 104516745A
- Authority
- CN
- China
- Prior art keywords
- asp
- net
- application domain
- task
- event
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Abstract
The invention discloses a method and a system for running an Asp.Net timing task. The method includes the steps: creating a task activator; acquiring an application domain of an Asp.Net site, and registering the task activator in an application domain unloading event and an application domain parent process exit event of the application domain; executing the application domain unloading event or the application domain parent process exit event to execute the task activator when the Asp.Net site is recovered by an IIS (internet information server); restarting the Asp.Net site through the task activator; creating and running the Asp.Net timing task on the restarted Asp.Net site. Stable running of the timing task is realized without reducing the performance of the IIS.
Description
Technical field
The present invention relates to computer realm, particularly a kind of method and system of run timing task.
Background technology
Many times, program needs some tasks of execution in background thread timing, such as timed sending mail.Independent Windows Service is when run timing task, and its stability is better, but needs to install separately, causes and disposes complicated problem; Therefore, the backstage timed task within the Asp.Net process being additional to lightweight relies on it conveniently to dispose, does not need the advantages such as installation separately, is provided with applies widely in internet addiction disorder field; Described Asp.Net is the class libraries being used for developing Web page application program provided in .Net framework by Microsoft, is the .Net version of Active Server Pages Asp.
But, because Asp.Net process runs among Internet Information Service IIS, so be additional to the backstage timed task within Asp.Net process, be just easily subject to the impact that the timing of IIS application program is reclaimed, cause the result that backstage timed task instability or backstage timed task do not run.If arrange endless or idle overtime endless by the interval time that the timing of IIS application program is reclaimed, avoid IIS application call the automatic recovery, IIS performance will be reduced.
Summary of the invention
The method and system of a kind of run timing task provided by the invention, to solve under the prerequisite not reducing IIS performance, realize the problem of timed task stable operation.
The invention provides a kind of method of Asp.Net run timing task, described method comprises:
Creation task activator appliance;
Obtain the Application Domain of Asp.Net website, the Application Domain unloading event and the Application Domain parent process that described Task Activator are registered in described Application Domain exit in event;
When described Asp.Net website is reclaimed by Internet Information Service IIS, perform described Application Domain unloading event or described Application Domain parent process exits event, described Task Activator is performed;
Described Asp.Net website is restarted by described Task Activator;
The described Asp.Net website restarted creates and runs Asp.Net timed task.
Preferably, described described Task Activator is registered in described Application Domain Application Domain unloading event and after Application Domain parent process exits in event, described method also comprises:
Described Application Domain unloading event and Application Domain parent process exit the Asp.Net site parameter that event obtains described Asp.Net website respectively; Accordingly, describedly restart described Asp.Net website by described Task Activator and be specially:
The described Asp.Net site parameter that the event that described Application Domain unloading event or Application Domain parent process exited obtains notifies described Task Activator, restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator.
Preferably, describedly restart described Asp.Net website according to described Asp.Net site parameter by Task Activator and comprise: create Http client, sent the request message restarting described Asp.Net website by described Http client, in described request message, comprise described Asp.Net site parameter; Receive the Http state return code returning to described Http client; When the described Http state return code that described Http client receives is 200, restart described Asp.Net website.
Preferably, comprise before the Application Domain of described acquisition Asp.Net website: judge whether Asp.Net website is start first time, if not, then exit; If so, the Application Domain of described acquisition Asp.Net website is then performed.
Preferably, described method is realized by Http module interface.
The present invention also provides a kind of system of Asp.Net run timing task, and described system comprises:
Creating unit, for creation task activator appliance;
Registering unit, for obtaining the Application Domain of Asp.Net website, the Application Domain unloading event and the Application Domain parent process that described Task Activator are registered in described Application Domain exit in event;
Performance element, for when described Asp.Net website is reclaimed by Internet Information Service IIS, performs described Application Domain unloading event or described Application Domain parent process exits event, described Task Activator is performed;
Restart unit, for restarting Asp.Net website by described Task Activator;
Create running unit, for creating on the described Asp.Net website restarted and running Asp.Net timed task.
Preferably, described system also comprises: parameter acquiring unit, after the Application Domain unloading event described Task Activator being registered in described Application Domain for described and Application Domain parent process exit in event, described Application Domain unloading event and Application Domain parent process exit the Asp.Net site parameter that event obtains described Asp.Net website respectively;
Accordingly, describedly restart unit, the described Asp.Net site parameter obtained specifically for described Application Domain unloading event or Application Domain parent process being exited event notifies described Task Activator, restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator.
Preferably, restart unit described in comprise: request subelement, for creating Http client, being sent the request message restarting described Asp.Net website, comprising described Asp.Net site parameter in described request message by described Http client; Receive subelement, for receiving the Http state return code returning to described Http client; Promoter unit, when the described Http state return code for receiving when described Http client is 200, restarts Asp.Net website.
Preferably, described system also comprises: identifying unit, before the Application Domain for described acquisition Asp.Net website, judges whether Asp.Net website is start first time, if not, then exit; If so, then registering unit is performed.
Preferably, described system is realized by Http module interface.
The beneficial effect of the embodiment of the present invention is: by Task Activator being registered in Application Domain unloading event and Application Domain parent process exits in event, make when described Asp.Net website is reclaimed by Internet Information Service IIS, any one event in these two events is performed, described Task Activator will be made to be performed, and during described Task Activator execution, Asp.Net website is restarted, and then make Asp.Net timed task be subsequently supplied and perform, achieve the stable operation of timed task, also do not affect IIS performance.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of the method for a kind of Asp.Net run timing task of one embodiment of the invention;
Fig. 2 is the detail flowchart of the method for a kind of Asp.Net run timing task of one embodiment of the invention;
Fig. 3 is the structural drawing of the system of a kind of Asp.Net run timing task of one embodiment of the invention.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
As shown in Figure 1, the invention provides a kind of method of Asp.Net run timing task, described method comprises:
S110, creation task activator appliance;
The Application Domain AppDomain of S120, acquisition Asp.Net website, the Application Domain unloading event AppDomain.DomainUnload and the Application Domain parent process that described Task Activator are registered in described Application Domain exit in event AppDomain.ProcessExit;
S130, when described Asp.Net website is reclaimed by Internet Information Service IIS, perform described Application Domain unloading event AppDomain.DomainUnload or described Application Domain parent process exits event AppDomain.ProcessExit, described Task Activator is performed;
S140, restart described Asp.Net website by described Task Activator;
S150, the described Asp.Net website restarted creates and runs Asp.Net timed task.
In one embodiment of the invention, described described Task Activator is registered in described Application Domain Application Domain unloading event and Application Domain parent process exit in event after also comprise: described Application Domain unloading event and Application Domain parent process exit event and obtain Asp.Net site parameter respectively; Accordingly, describedly restart described Asp.Net website by described Task Activator and can be: the described Asp.Net site parameter that the event that described Application Domain unloading event or Application Domain parent process exited obtains notifies described Task Activator, restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator.
In one embodiment of the invention, describedly restart described Asp.Net website according to described Asp.Net site parameter by Task Activator and comprise: create Http client, sent the request message restarting described Asp.Net website by described Http client, in described request message, comprise described Asp.Net site parameter; Receive the Http state return code returning to described Http client; When the described Http state return code that described Http client receives is 200, restart described Asp.Net website.
In one embodiment of the invention, also comprise before the Application Domain of described acquisition Asp.Net website: judge whether Asp.Net website is start first time, if not, then exit; If so, the Application Domain of described acquisition Asp.Net website is then performed.
In one embodiment of the invention, described method is realized by Http module interface.
The beneficial effect of the embodiment of the present invention is: by Task Activator being registered in Application Domain unloading event and Application Domain parent process exits in event, make when described Asp.Net website is reclaimed by Internet Information Service IIS, any one event in these two events is performed, described Task Activator will be made to be performed, and during described Task Activator execution, Asp.Net website is restarted, and then make Asp.Net timed task be subsequently supplied and perform, achieve the stable operation of timed task, also do not affect IIS performance.
Fig. 2 is the concrete implementation step of a kind of Asp.Net run timing task provided by the invention:
By this interface, S210, registration Http module interface, judge whether Asp.Net website is first time startup, if so, then creation task scheduler, if not, then exit;
Wherein, the working cell of a plan target is a task, and corresponding program of executing the task just is called task dispatcher, and task dispatcher comprises one or more task, and each task realizes task interface ISchedulerjob.
S220, establishment timed task, poll verifies the interface ISchedulerjob that whether executes the task, and if so, then starts this timed task by task dispatcher, if not, then exit;
S230, creation task activator appliance;
The effect of described Task Activator is when described Asp.Net website is reclaimed by Internet Information Service IIS, and request Asp.Net website makes Asp.Net website restart.
S240, judge that whether Asp.Net website is start first time, if not, then exit; If so, then obtain the Application Domain of Asp.Net website, the Application Domain unloading event and the Application Domain parent process that described Task Activator are registered in Application Domain exit in event;
S250, described Application Domain unloading event and Application Domain parent process exit event and obtain Asp.Net site parameter respectively; And the described Asp.Net site parameter notice Task Activator that will obtain;
Wherein, described Asp.Net site parameter is Asp.Net site address and journal file path parameter;
S260, when described Asp.Net website is reclaimed by Internet Information Service IIS, executive utility territory unloading event or Application Domain parent process exit event, and described Task Activator is performed;
S270, described Task Activator restart described Asp.Net website according to described Asp.Net site parameter; Specifically comprise:
(1) create Http client, according to described Asp.Net site address, sent the request restarting described Asp.Net website to Asp.Net website by Http client;
(2) described Asp.Net website receives described request and a newly-built Application Domain, the request of Http client described in this newly-built application program domain response, and returns Http state return code;
(3), after Http client receives Http state return code, judge that described Http state return code is 200;
When described Http state return code is 200, the success of Asp.Net site requests is described, then restarts described Asp.Net website; If described Http state return code is not 200, the failure of Asp.Net site requests is described, then described Asp.Net website can not restart, the then journal file path parameter of misregistration, and after making current thread dormancy certain hour, continue to send request to Asp.Net website, until exit when the Http state return code that Http client receives is 200;
Preferably, after usually making current thread dormancy 10s, continue to send request to Asp.Net website.
S280, the Asp.Net website restarted re-creates and runs Asp.Net timed task.
After described Asp.Net website is reclaimed by Internet Information Service IIS, the former timed task loaded on Asp.Net website does not also exist; After Asp.Net website is restarted, need to re-create the former timed task be by mistake recovered, wherein the visioning procedure of timed task will re-execute according to S210-S220.
The present embodiment does not do any restriction to the execution sequence of S220 and S230, does not repeat them here.
The beneficial effect of the embodiment of the present invention is: by Task Activator being registered in Application Domain unloading event and Application Domain parent process exits in event, make when described Asp.Net website is reclaimed by Internet Information Service IIS, any one event in these two events is performed, described Task Activator will be made to be performed, and during described Task Activator execution, Asp.Net website is restarted, and then make Asp.Net timed task be subsequently supplied and perform, achieve the stable operation of timed task, also do not affect IIS performance.
As shown in Figure 3, the present invention also provides a kind of system 300 of Asp.Net run timing task, and described system comprises:
Creating unit 310, for creation task activator appliance;
Registering unit 320, for obtaining the Application Domain of Asp.Net website, the Application Domain unloading event and the Application Domain parent process that described Task Activator are registered in described Application Domain exit in event;
Performance element 330, for when described Asp.Net website is reclaimed by Internet Information Service IIS, performs described Application Domain unloading event or described Application Domain parent process exits event, described Task Activator is performed;
Restart unit 340, for restarting Asp.Net website by described Task Activator;
Create running unit 350, for creating on the described Asp.Net website restarted and running Asp.Net timed task.
In one embodiment of the invention, described system also comprises: parameter acquiring unit, after the Application Domain unloading event described Task Activator being registered in described Application Domain for described and Application Domain parent process exit in event, described Application Domain unloading event and Application Domain parent process exit the Asp.Net site parameter that event obtains described Asp.Net website respectively;
Accordingly, describedly restart unit, the described Asp.Net site parameter obtained specifically for described Application Domain unloading event or Application Domain parent process being exited event notifies described Task Activator, restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator.
In one embodiment of the invention, restart unit described in comprise:
Request subelement, for creating Http client, being sent the request message restarting described Asp.Net website, comprising described Asp.Net site parameter in described request message by described Http client;
Receive subelement, for receiving the Http state return code returning to described Http client;
Promoter unit, when the described Http state return code for receiving when described Http client is 200, restarts Asp.Net website.
In one embodiment of the invention, described system also comprises:
Identifying unit, before the Application Domain for described acquisition Asp.Net website, judges whether Asp.Net website is start first time, if not, then exit; If so, then registering unit 320 is performed.
In one embodiment of the invention, described system is realized by Http module interface.
The beneficial effect of the embodiment of the present invention is: by Task Activator being registered in Application Domain unloading event and Application Domain parent process exits in event, make when described Asp.Net website is reclaimed by Internet Information Service IIS, any one event in these two events is performed, described Task Activator will be made to be performed, and during described Task Activator execution, Asp.Net website is restarted, and then make Asp.Net timed task be subsequently supplied and perform, achieve the stable operation of timed task, also do not affect IIS performance.
The foregoing is only preferred embodiment of the present invention, be not intended to limit protection scope of the present invention.All any amendments done within the spirit and principles in the present invention, equivalent replacement, improvement etc., be all included in protection scope of the present invention.
Claims (10)
1. a method for Asp.Net run timing task, is characterized in that, described method comprises:
Creation task activator appliance;
Obtain the Application Domain of Asp.Net website, the Application Domain unloading event and the Application Domain parent process that described Task Activator are registered in described Application Domain exit in event;
When described Asp.Net website is reclaimed by Internet Information Service IIS, perform described Application Domain unloading event or described Application Domain parent process exits event, described Task Activator is performed;
Described Asp.Net website is restarted by described Task Activator;
The described Asp.Net website restarted creates and runs Asp.Net timed task.
2. the method for claim 1, is characterized in that, described described Task Activator is registered in described Application Domain Application Domain unloading event and after Application Domain parent process exits in event, described method also comprises:
Described Application Domain unloading event and Application Domain parent process exit the Asp.Net site parameter that event obtains described Asp.Net website respectively;
Accordingly, describedly restart described Asp.Net website by described Task Activator and be specially:
The described Asp.Net site parameter that the event that described Application Domain unloading event or Application Domain parent process exited obtains notifies described Task Activator, restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator.
3. method as claimed in claim 2, is characterized in that, describedly restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator and comprises:
Create Http client, sent the request message restarting described Asp.Net website by described Http client, in described request message, comprise described Asp.Net site parameter;
Receive the Http state return code returning to described Http client;
When the described Http state return code that described Http client receives is 200, restart described Asp.Net website.
4. the method for claim 1, is characterized in that, also comprises before the Application Domain of described acquisition Asp.Net website:
Judge whether Asp.Net website is start first time, if not, then exit; If so, the Application Domain of described acquisition Asp.Net website is then performed.
5. the method for claim 1, is characterized in that, described method is realized by Http module interface.
6. a system for Asp.Net run timing task, is characterized in that, described system comprises:
Creating unit, for creation task activator appliance;
Registering unit, for obtaining the Application Domain of Asp.Net website, the Application Domain unloading event and the Application Domain parent process that described Task Activator are registered in described Application Domain exit in event;
Performance element, for when described Asp.Net website is reclaimed by Internet Information Service IIS, performs described Application Domain unloading event or described Application Domain parent process exits event, described Task Activator is performed;
Restart unit, for restarting Asp.Net website by described Task Activator;
Create running unit, for creating on the described Asp.Net website restarted and running Asp.Net timed task.
7. system as claimed in claim 6, it is characterized in that, described system also comprises:
Parameter acquiring unit, after the Application Domain unloading event described Task Activator being registered in described Application Domain for described and Application Domain parent process exit in event, described Application Domain unloading event and Application Domain parent process exit the Asp.Net site parameter that event obtains described Asp.Net website respectively;
Accordingly, describedly restart unit, the described Asp.Net site parameter obtained specifically for described Application Domain unloading event or Application Domain parent process being exited event notifies described Task Activator, restarts described Asp.Net website according to described Asp.Net site parameter by Task Activator.
8. system as claimed in claim 7, is characterized in that, described in restart unit and comprise:
Request subelement, for creating Http client, being sent the request message restarting described Asp.Net website, comprising described Asp.Net site parameter in described request message by described Http client;
Receive subelement, for receiving the Http state return code returning to described Http client;
Promoter unit, when the described Http state return code for receiving when described Http client is 200, restarts Asp.Net website.
9. system as claimed in claim 6, it is characterized in that, described system also comprises:
Identifying unit, before the Application Domain for described acquisition Asp.Net website, judges whether Asp.Net website is start first time, if not, then exit; If so, then registering unit is performed.
10. system as claimed in claim 6, it is characterized in that, described system is realized by Http module interface.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310451795.3A CN104516745B (en) | 2013-09-27 | 2013-09-27 | A kind of method and system of run timing task |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310451795.3A CN104516745B (en) | 2013-09-27 | 2013-09-27 | A kind of method and system of run timing task |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104516745A true CN104516745A (en) | 2015-04-15 |
CN104516745B CN104516745B (en) | 2018-09-04 |
Family
ID=52792110
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310451795.3A Active CN104516745B (en) | 2013-09-27 | 2013-09-27 | A kind of method and system of run timing task |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104516745B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107391188A (en) * | 2017-07-17 | 2017-11-24 | 聚好看科技股份有限公司 | A kind of method and apparatus for controlling timed task |
CN108008983A (en) * | 2017-09-30 | 2018-05-08 | 浙江中控软件技术有限公司 | Multi-interface data processing method based on one process |
CN110019631A (en) * | 2017-12-28 | 2019-07-16 | 浙江宇视科技有限公司 | The processing method and processing device of multi-dimensional map |
CN110221906A (en) * | 2019-05-24 | 2019-09-10 | 吉首大学 | A kind of method and system of Asp.Net run timing task |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101566945A (en) * | 2008-04-25 | 2009-10-28 | 北京闻言科技有限公司 | Method for flexibly using weak reference cache object |
CN102739680A (en) * | 2012-06-28 | 2012-10-17 | 用友软件股份有限公司 | Session life prolonging device and method |
-
2013
- 2013-09-27 CN CN201310451795.3A patent/CN104516745B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101566945A (en) * | 2008-04-25 | 2009-10-28 | 北京闻言科技有限公司 | Method for flexibly using weak reference cache object |
CN102739680A (en) * | 2012-06-28 | 2012-10-17 | 用友软件股份有限公司 | Session life prolonging device and method |
Non-Patent Citations (1)
Title |
---|
红黑联盟: "IIS 自动回收导致后台定时器失效的问题解决", 《HTTP://WWW.2CTO.COM/KF/201112/115331.HTML》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107391188A (en) * | 2017-07-17 | 2017-11-24 | 聚好看科技股份有限公司 | A kind of method and apparatus for controlling timed task |
CN108008983A (en) * | 2017-09-30 | 2018-05-08 | 浙江中控软件技术有限公司 | Multi-interface data processing method based on one process |
CN108008983B (en) * | 2017-09-30 | 2023-12-15 | 浙江中控软件技术有限公司 | Multi-interface data processing method based on single process |
CN110019631A (en) * | 2017-12-28 | 2019-07-16 | 浙江宇视科技有限公司 | The processing method and processing device of multi-dimensional map |
CN110019631B (en) * | 2017-12-28 | 2021-11-16 | 浙江宇视科技有限公司 | Method and device for processing multi-dimensional map |
CN110221906A (en) * | 2019-05-24 | 2019-09-10 | 吉首大学 | A kind of method and system of Asp.Net run timing task |
Also Published As
Publication number | Publication date |
---|---|
CN104516745B (en) | 2018-09-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11256539B2 (en) | Task processing method, apparatus, and system based on distributed system | |
US9152410B2 (en) | Auto-update while running client interface with handshake | |
CN108011931B (en) | Web data acquisition method and Web data acquisition system | |
CN104516745A (en) | Method and system for running timing task | |
CN110196761B (en) | Delayed task processing method and device | |
US9203896B2 (en) | Method and apparatus for data interaction | |
WO2017193737A1 (en) | Software testing method and system | |
CN109982355B (en) | Method for saving and restoring network path, apparatus, terminal and storage medium thereof | |
CN103077034B (en) | hybrid virtualization platform JAVA application migration method and system | |
CN111913793A (en) | Distributed task scheduling method, device, node equipment and system | |
CN107231386B (en) | Application state conversion method and device and mobile terminal | |
CN105095045A (en) | Method and system for monitoring background service of Android system | |
CN110737526A (en) | method and device for managing timed tasks under Redis-based distributed cluster | |
CN113542256B (en) | Method, device, equipment and storage medium for updating login credentials in client | |
CN111930561B (en) | Streaming task automatic monitoring alarm restarting system and method | |
CN110895485A (en) | Task scheduling system | |
CN104104969B (en) | Video interception method and device | |
WO2015021827A1 (en) | Method,device and system for offline reconnection of a web application | |
CN111897543A (en) | Software management method, device, management equipment and storage medium | |
CN101944056B (en) | Method and device for monitoring multitask system | |
CN109491841A (en) | A method of improving Spark on yarn real-time task reliability | |
CN114201458B (en) | Information updating method, micro-service system and computer readable storage medium | |
CN106325979B (en) | Virtual machine deployment method and device and network function virtualization orchestration NVFO | |
CN113886049A (en) | Timed task running method and device and computer equipment | |
CN102915257A (en) | TORQUE(tera-scale open-source resource and queue manager)-based parallel checkpoint execution method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP02 | Change in the address of a patent holder |
Address after: Room 810, 8 / F, 34 Haidian Street, Haidian District, Beijing 100080 Patentee after: BEIJING D-MEDIA COMMUNICATION TECHNOLOGY Co.,Ltd. Address before: 100089 Beijing city Haidian District wanquanzhuang Road No. 28 Wanliu new building 6 storey block A room 602 Patentee before: BEIJING D-MEDIA COMMUNICATION TECHNOLOGY Co.,Ltd. |
|
CP02 | Change in the address of a patent holder |