(As I'm new to WCF) I want to add Quartz in Windows Communication Foundation (WCF) project. And I also wants to know that which file or method execute first after run the application.
CodePudding user response:
Instead of using Quartz, I used C# Timer. The Timer class in C# represents a Timer control that executes a code block at a specified interval of time repeatedly.
//Timer Class
public class FileJob
{
private System.Timers.Timer ProcessTimer;
public void Start()
{
try
{
ProcessTimer = new System.Timers.Timer();
ProcessTimer.AutoReset = true;
ProcessTimer.Elapsed = new System.Timers.ElapsedEventHandler(ProcessTimer_Elapsed);
ProcessTimer.Interval = 300000; //5 minutes
ProcessTimer.Start();
}
catch (Exception ex)
{ }
}
private void ProcessTimer_Elapsed(object sender, EventArgs e)
{
UploadFile();
}
}
Global.asax.cs
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
FileJob obj = new FileJob();
obj.Start();
}
}