Repository: dotnet/aspnetcore
File: src/Hosting/WindowsServices/src/WebHostService.cs (C#)

Code before:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.ServiceProcess;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Microsoft.AspNetCore.Hosting.WindowsServices;

/// <summary>
///     Provides an implementation of a Windows service that hosts ASP.NET Core.
/// </summary>
[DesignerCategory("Code")]
[Obsolete("Use UseWindowsService and AddHostedService instead.", DiagnosticId = "ASPDEPR009")]
public class WebHostService : ServiceBase
{
    private readonly IWebHost _host;
    private bool _stopRequestedByWindows;

    /// <summary>
    /// Creates an instance of <c>WebHostService</c> which hosts the specified web application.
    /// </summary>
    /// <param name="host">The configured web host containing the web application to host in the Windows service.</param>
    public WebHostService(IWebHost host)
    {
        _host = host ?? throw new ArgumentNullException(nameof(host));
    }

    /// <summary>
    /// This method is not intended for direct use. Its sole purpose is to allow
    /// the service to be started by the tests.
    /// </summary>
    internal void Start() => OnStart(Array.Empty<string>());

    /// <inheritdoc />
    protected sealed override void OnStart(string[] args)
    {
        OnStarting(args);


Review comment (suggestion):
```suggestion
[Obsolete("Use UseWindowsService and AddHostedService instead. For more information, visit https://aka.ms/aspnet/deprecate/009.", DiagnosticId = "ASPDEPR009")]
```

Code after:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.ServiceProcess;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Microsoft.AspNetCore.Hosting.WindowsServices;

/// <summary>
///     Provides an implementation of a Windows service that hosts ASP.NET Core.
/// </summary>
[DesignerCategory("Code")]
[Obsolete("Use UseWindowsService and AddHostedService instead. For more information, visit https://aka.ms/aspnet/deprecate/009.", DiagnosticId = "ASPDEPR009")]
public class WebHostService : ServiceBase
{
    private readonly IWebHost _host;
    private bool _stopRequestedByWindows;

    /// <summary>
    /// Creates an instance of <c>WebHostService</c> which hosts the specified web application.
    /// </summary>
    /// <param name="host">The configured web host containing the web application to host in the Windows service.</param>
    public WebHostService(IWebHost host)
    {
        _host = host ?? throw new ArgumentNullException(nameof(host));
    }

    /// <summary>
    /// This method is not intended for direct use. Its sole purpose is to allow
    /// the service to be started by the tests.
    /// </summary>
    internal void Start() => OnStart(Array.Empty<string>());

    /// <inheritdoc />
    protected sealed override void OnStart(string[] args)
    {
        OnStarting(args);