Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stop / clear all tasks? #408

Open
fatihyildizhan opened this issue Sep 26, 2024 · 2 comments
Open

How to stop / clear all tasks? #408

fatihyildizhan opened this issue Sep 26, 2024 · 2 comments

Comments

@fatihyildizhan
Copy link

Hello,

I was trying and created multiple tasks and couldn't stop them.

I want to stop all of them. Is there a way to do this?

Thank you very much for your time

Tried these:

  1. Stop scheduled job #371
  2. How to stop scheduled task? #385
  3. Question: How do you un-schedule invocables? #216
@fatihyildizhan
Copy link
Author

Hello,

When I make changes to Task1 or Task2 and send it to the server, sometimes it starts working more than once.

For example, 3 Task1s start working EveryTenMinutes on the server.

How can I delete all the existing Tasks before scheduling?

Thank you for your time.

public class Task1 : IInvocable
{
    public async Task Invoke()
    {
        // do something
    }
}
app.Services.UseScheduler(scheduler =>
{
    scheduler.OnWorker("Task1Worker");
    scheduler.Schedule<Task1>()
    .EveryTenMinutes()
    .RunOnceAtStart()
    .PreventOverlapping("Task1");

    scheduler.OnWorker("Task2Worker");
    scheduler.Schedule<Task2>()
    .EveryTenMinutes()
    .RunOnceAtStart()
    .PreventOverlapping("Task2");
})
.OnError((exception) =>
    Console.WriteLine(exception.ToString())
);

@jamesmh
Copy link
Owner

jamesmh commented Oct 11, 2024

There is no API to clear the scheduler.

If you really need this, you could attach and id to every job you've scheduled (see here) and then unschedule all of the jobs manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants