I am trying to get familiar with C# FluentScheduler library through a console application (.Net Framework 4.5.2). Below is the code that have written:
class Program
{
static void Main(string[] args)
{
JobManager.Initialize(new MyRegistry());
}
}
public class MyRegistry : Registry
{
public MyRegistry()
{
Action someMethod = new Action(() =>
{
Console.WriteLine("Timed Task - Will run now");
});
Schedule schedule = new Schedule(someMethod);
schedule.ToRunNow();
}
}
This code executes without any errors but I don't see anything written on Console. Am I missing something here?
You are using the library the wrong way - you should not create a new Schedule
.
You should use the Method that is within the Registry
.
public class MyRegistry : Registry
{
public MyRegistry()
{
Action someMethod = new Action(() =>
{
Console.WriteLine("Timed Task - Will run now");
});
// Schedule schedule = new Schedule(someMethod);
// schedule.ToRunNow();
this.Schedule(someMethod).ToRunNow();
}
}
The second issue is that the console application will immediately exit after the initialization, so add a Console.ReadLine()
static void Main(string[] args)
{
JobManager.Initialize(new MyRegistry());
Console.ReadLine();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With