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

Fix app not disposing service host correctly #1679

Merged
merged 3 commits into from
Jun 24, 2024
Merged

Fix app not disposing service host correctly #1679

merged 3 commits into from
Jun 24, 2024

Conversation

Al12rs
Copy link
Contributor

@Al12rs Al12rs commented Jun 24, 2024

Closing app with ongoing downloads caused infinite hang, had to make several adjustments to get the app to close cleanly for now.

Downloads are currently cancelled on close, fixing that will require more involved changes for another PR.

See commit messages for details on reasons for some of the changes.
Open to suggestions for better approaches as I'm not necessarily convinced this to be the best solution.

Service definition order is used to determine the order of `StartAsync()` calls.
Inverse order is used for `StopAsync()`.
…) downloads before application close.

Business logic such as pausing/cancelling downloads should happen in StopAsync rather than DisposeAsync.

Converting this to IHostedService also means that the class is instantiated before StartAsync is called on the Host,
meaning that DB connection would not be initialized.

DB related logic had to regrettably be moved to StartAsync instead, where DB would be available and initialized already.
@Al12rs Al12rs requested a review from a team June 24, 2024 14:31
@Al12rs Al12rs self-assigned this Jun 24, 2024
@Al12rs Al12rs merged commit 5c78d90 into main Jun 24, 2024
10 checks passed
@Al12rs Al12rs deleted the fix/dispose-di branch June 24, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants