简体   繁体   中英

Call a method in a TaskService?

I am using a Taskscheduler in my application after some time interval i want to run/call a method, after my application has started.

using (TaskService ts = new TaskService())
{
    TaskDefinition td = ts.NewTask();
    td.RegistrationInfo.Description = "Open App";

    Trigger tg = Trigger.CreateTrigger(TaskTriggerType.Time);
    Trigger tri = Trigger.CreateTrigger(TaskTriggerType.Event);
}

I have a method like Getdata(). And I want to call this method in scheduled time(Like Daily 10:30AM).

Please help.

You could use an open-source library such as FluentScheduler to easily perform any action at a given time.

Just use NuGet to download FluentScheduler: https://www.nuget.org/packages/FluentScheduler/

...and try this:

Schedule(() => GetData()).ToRunEvery(1).Days().At(10, 30);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM