Here is a real case:
A project has a requirement that needs to be timed to invoke the WebService of a web system in another company to import the data from their systems into our system. Because it is a call to the Web interface, it cannot be implemented using the task schedule in the database. It was later thought to use the time component to take advantage of the application in global.
Using System;
Using System.Collections;
Using System.Configuration;
Using System.Data;
Using System.Linq;
Using System.Web;
Using System.Web.Security;
Using System.Web.SessionState;
Using System.Xml.Linq; Namespace MyNet {public class Global:System.Web.HttpApplication {protected void Application_Start (object se
NDEr, EventArgs e) {System.Timers.Timer timer1 = new System.Timers.Timer (); Timer1. Interval = 30000; 30000 ms = 30 sec timer1.
Elapsed + = new System.Timers.ElapsedEventHandler (time1_elapsed); Timer1.
Autoreset = true; Timer1.
Enabled = true; Timer1.
Start (); } protected void Session_Start (object sender, EventArgs e) {} protected void Application_beginreques T (object sender, EventArgs e) {} protected void Application_AuthenticateRequest (object sender, EventArgs E {} protected void Application_Error (object sender, EventArgs e) {} protected void Sessio N_end (obJect sender, EventArgs e) {} protected void Application_End (object sender, EventArgs e) {} void Time1_elapsed (object source, System.Timers.ElapsedEventArgs e) {localhost. MyWebService ws = new localhost.
MyWebService (); Ws.
Insertmywebservice (); }
}
}
Note: The system will not be affected by multiple users, but the system must be used by at least one user, otherwise the timer program will not execute.
The above content introduced asp.net how to call the WebService service method regularly, hoped to have the help to everybody's study.