Skip to content

ServiceBase should not accept SERVICE_CONTROL_STOP during SERVICE_START_PENDING #23173

@mattyellen

Description

@mattyellen

Microsoft best practices (as documented in SetServiceStatus) states:

Do not register to accept controls while the status is SERVICE_START_PENDING or the service can crash. After initialization is completed, accept the SERVICE_CONTROL_STOP code.

However in ServiceBase.ServiceMainCallback if the service has been configured with CanStop = true it sets the status to accept SERVICE_CONTROL_STOP right away.

Also since CanStop cannot be changed after OnStart is called, there does not appear to be a way to work around this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions