Open Closed

Background worker freezee for the first time run service #9238


User avatar
0
FPT_TuyenDN1 created

When I register a background worker and run the service for the first time, it always freezes, as shown in the log below:

After I rerun it 2-3 times, it will be fine. My code registers like this:

I don't know why it gets stuck. Please help me how to fix it to run the service more stably.


2 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, thanks for sharing your background worker implementation and the issue you're encountering. It occurred to me the reason is: Quartz Scheduler Initialization Delay or Deadlock

    When the application runs for the first time, the Quartz scheduler might not have fully initialized before ScheduleJob is executed. This can cause the worker to hang or time out.

    ✅As a solution: Move the Quartz scheduling logic to the Execute method instead of the constructor. Avoid heavy logic in constructors — especially logic that includes async calls or service resolutions.

  • User Avatar
    0
    FPT_TuyenDN1 created

    Hi, thanks for sharing your background worker implementation and the issue you're encountering. It occurred to me the reason is: Quartz Scheduler Initialization Delay or Deadlock

    When the application runs for the first time, the Quartz scheduler might not have fully initialized before ScheduleJob is executed. This can cause the worker to hang or time out.

    ✅As a solution: Move the Quartz scheduling logic to the Execute method instead of the constructor. Avoid heavy logic in constructors — especially logic that includes async calls or service resolutions.

    Thank you for sharing. it work fine after i move Quartz scheduling logic to the Execute

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on May 15, 2025, 10:28