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

Jobs start immediately even if ToRunNow() is not called #263

Open
thomasrea0113 opened this issue Dec 6, 2019 · 4 comments
Open

Jobs start immediately even if ToRunNow() is not called #263

thomasrea0113 opened this issue Dec 6, 2019 · 4 comments
Labels

Comments

@thomasrea0113
Copy link

    public class TestRegistry : Registry
    {
        public TestRegistry()
        {
            Schedule(() =>
            {
                while (true)
                {
                    var log = NLog.LogManager.GetLogger("Logger1");
                    log.Info("sleeping 1...");
                    Thread.Sleep(100);
                }
            })
            .WithName("Infinite Task")
            .NonReentrant()
            .ToRunNow();
            Schedule(() =>
            {
                while (true)
                {
                    var log = NLog.LogManager.GetLogger("Logger2");
                    log.Info("sleeping 2...");
                    Thread.Sleep(100);
                }
            })
            .WithName("Infinite Task (Not Running)")
            .NonReentrant();
        }
    }

The above registry will start both jobs even when ToRunNow() is not called on the second schedule. Ideally, the Registry class should make Schedules public so that we can retrieve scheduels at a later time and run them manually. Alternatively, One-off jobs should also be added to AllSchedules (or another AllJobs property should be made available) so that each job can be registered and scheduled at a later day. That should only require adding the job to the collection above this line.

My use-case right now it to create a task schedule - so I need to define the jobs now, and let the user schedule them at a later day. I don't want them to run at startup. For this purpose, registry is essentially useless. I'll be better off subscribing to the job events and manually calling add/remove job.

@tallesl
Copy link
Contributor

tallesl commented Aug 2, 2020

You're totally right, I'm also aware of that. I'm flagging this issue as a bug and leaving it open.

Being honest here: since this doesn't affect the other schedules, and there's an on-going library redesign, I'll probably not fix it.

@tallesl tallesl added the bug label Aug 2, 2020
@thomasrea0113
Copy link
Author

You're totally right, I'm also aware of that. I'm flagging this issue as a bug and leaving it open.

Being honest here: since this doesn't affect the other schedules, and there's an on-going library redesign, I'll probably not fix it.

Thanks for the update! As long as the redesign keeps my points in mind, I'll be happy. This project is my favorite open source scheduler by far, and these improvements would make things so much easier

@tallesl
Copy link
Contributor

tallesl commented Aug 2, 2020

That's so kind of you, thanks.

I'm doing some quality of life updates on version 5 (mainly newer .net standard and async job support) and some housekeeping on existing issues, then I'm back to work on version 6 (currently in alpha).

As for being your favorite open-source scheduler, please stay around. It's taking ages, but we're so close to finishing up version 6 (it's just missing reentrancy IIRC). After that, it should be much more pleasant taking new features suggestions and accepting merge requests.

@thomasrea0113
Copy link
Author

Just wondering what the status was on this? I'd still love to see this, and it seems at least one other user is looking for something similar.

ce6b4d6#commitcomment-44086754

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

No branches or pull requests

2 participants