dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.25k stars 4.73k forks source link

Include support for OnPowerEvent in .net core worker services #50014

Open GZidar opened 4 years ago

GZidar commented 4 years ago

Has there been any consideration given to allowing the net core worker services to receive notifications from the OS when a device is put to sleep or resumes from sleep. This is available in the .net framework System.ServiceProcess.ServiceBase classes but does not appear to have an equivalent in the worker service implementations.

Is there any way to do this already?

Describe the solution you'd like

The way this is done in the System.ServiceProcess.ServiceBase seems like a reasonable approach. Service hooks into OS level events that allow the developer to customize how their service reacts to the various messages.

Additional context

Ideally this would be available on all platforms but if that is not possible then perhaps it should be accessed via the WindowsServiceLifetime hooks (or something)

ghost commented 4 years ago

Tagging subscribers to this area: @eerhardt, @maryamariyan See info in area-owners.md if you want to be subscribed.

davidfowl commented 4 years ago

It might be better to give people a way to get the raw events from service base somehow

danmoseley commented 3 years ago

What are "worker services" in this context?

davidfowl commented 3 years ago

What are "worker services" in this context?

image

It's a console app hooked up to Microsoft.Extensions.Hosting.

ghost commented 3 years ago

Tagging subscribers to this area: @eerhardt, @maryamariyan See info in area-owners.md if you want to be subscribed.

Issue Details
Has there been any consideration given to allowing the net core worker services to receive notifications from the OS when a device is put to sleep or resumes from sleep. This is available in the .net framework System.ServiceProcess.ServiceBase classes but does not appear to have an equivalent in the worker service implementations. Is there any way to do this already? ### Describe the solution you'd like The way this is done in the System.ServiceProcess.ServiceBase seems like a reasonable approach. Service hooks into OS level events that allow the developer to customize how their service reacts to the various messages. ### Additional context Ideally this would be available on all platforms but if that is not possible then perhaps it should be accessed via the WindowsServiceLifetime hooks (or something)
Author: GZidar
Assignees: -
Labels: `area-System.ServiceProcess`, `untriaged`, `area-Extensions-Hosting`
Milestone: -
danmoseley commented 3 years ago

@GZidar perhaps you'd like to offer an API proposal in this issue similar to this template. You can edit the top post. https://github.com/dotnet/runtime/issues/new?assignees=&labels=api-suggestion&template=02_api_proposal.yml&title=%5BAPI+Proposal%5D%3A+