-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
RunOnceAtStart sometimes it doesn't work. #353
Comments
Not works for me in .net 8 with ScheduleAsync as well |
This is still an issue in Anything new on this issue? |
No news on this yet. Will look to investigate soon. Not sure what's going on at first glance. Unless someone else has any idea by looking at the source? |
Curious for those who reported this: what kind of machine was this on? A small container? Local machine with many threads? I have an idea of a potential race condition causing this, but can't reproduce at all ATM. |
Was able to reproduce via unit testing the suspect concurrency scenario. Fixed in 6.0.2! |
Please re-open if you find the issue persists. It's still possible that the issue has some other causes related to the .NET lifecycle 🤷. |
Still not works on my side with 6.0.2
desitnation method is called after several seconds |
🥲 Thanks @arteny - I'll have to take another gander at this. |
@arteny It's possible that there's another task causing this one to be delayed. If you put this task first in the list of all schedule tasks, does it improve things? |
For example: scheduler.Schedule(() => Thread.Sleep(10000)).EverySecond();
scheduler.ScheduleAsync(async () => { await Task.Delay(1); Console.WriteLine("SHOULD GO FIRST"); })
.Hourly()
.RunOnceAtStart(); Because the first task is not returning a That's what schedule workers are for. So this works: scheduler.Schedule(() => Thread.Sleep(10000)).EverySecond();
scheduler.OnWorker("TEST");
scheduler.ScheduleAsync(async () => { await Task.Delay(1); Console.WriteLine("SHOULD GO FIRST"); })
.Hourly()
.RunOnceAtStart(); This code will put the second scheduled task on it's own thread, so it's not blocked / waiting on the first task to complete. It might be the case that everyone or some of you guys/gals are experiencing this issue. Otherwise, I cannot reproduce this issue at all, other than this approach. So what I recommend for everyone having this issue is to either list these "run once at start" tasks first in your configuration (so they run first at run time) or put them on a dedicated worker. Let me know this works for anyone or doesn't! Thanks! |
Describe the bug
Affected Coravel Feature
Scheduling
Expected behaviour
Output content immediately when starting the program. ( "Start login xxx" and "Start refresh data") , but when I run it many times, sometimes it does not output content, and the console does not report any error message.
run windows service.
.net core 7.0
coravel : 5.0.2.0
The text was updated successfully, but these errors were encountered: