System.Timers virker ikke i web-service?
Jeg har lavet denne kode:using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Timers;
[WebService(Namespace = "http://services/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
private Timer controlInterval = new Timer(1000);
private static int i = 0;
public Service () {
}
[WebMethod]
public String runBackUpService(){
controlInterval.Interval = 500;
controlInterval.Enabled = true;
controlInterval.BeginInit();
controlInterval.Elapsed += new ElapsedEventHandler(controlInterval_Elapsed);
controlInterval.Start();
return "Running";
}
private static String UpdateBackup()
{
i++;
return "Service has elapsed: " + i + " times";
}
private static void controlInterval_Elapsed(object sender, ElapsedEventArgs e)
{
UpdateBackup();
}
}
Jeg forsøger blot at få servicen til at opdatere teksten, hvorfor virker det ikke??? :'(