Skip to content

Improve the JobWorker disposing #769

@xlegalles

Description

@xlegalles

Is your feature request related to a problem? Please describe.
The current Dispose() method stops the worker from polling jobs. But the current implementation uses a background task and does not wait for its termination to return. As a result, it is difficult to know when the worker is effectively stopped.
Our use case is the management of the Docker container termination: when we receive the SIGTERM, we must 1st stop the worker from polling, then wait for all current tasks to finish.

Describe the solution you'd like
We need a clear async method that stops the IJobWorker.

Describe alternatives you've considered
I propose 2 equivalent solutions:

  1. Implement a new async Stop() method
  2. Or better, implement the System.IAsyncDisposable

In both cases, the current Dispose() method would call the new async one just to not break the existing behavior.
We may consider marking the Dispose() method as obsolete and remove it later

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions