Create a job in windows service which calls a method in Wcf service

Hi

Is it possible to create a job in windows service which calls a method in Wcf service ? like below

RecurringJob.AddOrUpdate<ServiceReference1.Service1Client>(x => x.WriteOnTextFile("test from web service "), "* * * * *");

You can always wrap a method into another one.

I checked but it doesn’t work . can you give it a try in an example and see the result

Would you like to give me an example what you’ve checked?

Wrap the service call in a class.

public class MyJob
{
	private readonly IServiceClient client;

	MyJob(IServiceClient cl)
	{
		client = cl;
	}

	public void Execute()
	{
		try
		{
			
			client.ServiceMethod();
		}
		catch (Exception ex)
		{
			// Exeptionhandling here...
		}
	}
}


   AddOrUpdateRecurrent(() => job.Execute(JobCancellationToken.Null, job.Parameter), Cron, TimeZoneInfo.Local)