I have a simple task I was trying to get to repeat using FluentScheduler, but I can't seem to get it to run properly. I am entirely new to "Jobs" and "Actions", so I am sure it is something stupid I am not accounting for.
I am modifying my original question as the supplied solutions were working for a console app, but not a Windows Forms app. I have tried moving the line Application.Run(ThisForm);
to be before and after the JobManager
and the Task
, but it never updates the TextBox with the string.
public class Program
{
public class MyRegistry : Registry
{
public MyRegistry()
{
Action someMethod = new Action(() =>
{
Form1 ThisForm = new Form1();
ThisForm.Text ="HELLO";
});
this.Schedule(someMethod).ToRunNow().AndEvery(2).Seconds();
}
}
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(ThisForm);
JobManager.Initialize(new MyRegistry());
var t = Task.Run(async delegate
{
await Task.Delay(-1);
});
t.Wait();
}
}