using System;

namespace ZB.MOM.WW.MxGateway.Worker.Sta;

/// <summary>
///     Thrown by <see cref="StaRuntime"/> when an operation is rejected because
///     the runtime is shutting down (or has already shut down). The dedicated
///     type lets callers distinguish a graceful shutdown signal — which should
///     stop their work loops without recording a fault — from a genuine
///     programming-error <see cref="InvalidOperationException"/> such as the
///     STA-affinity assertion in <c>MxAccessStaSession.AssertOnAlarmConsumerThread</c>.
///     It inherits from <see cref="InvalidOperationException"/> so existing
///     callers that catch the latter remain source-compatible.
/// </summary>
public sealed class StaRuntimeShutdownException : InvalidOperationException
{
    /// <summary>
    ///     Initializes a new instance of <see cref="StaRuntimeShutdownException"/>
    ///     with a default message.
    /// </summary>
    public StaRuntimeShutdownException()
        : base("The worker STA runtime is shutting down.")
    {
    }

    /// <summary>
    ///     Initializes a new instance of <see cref="StaRuntimeShutdownException"/>
    ///     with the specified message.
    /// </summary>
    /// <param name="message">Diagnostic message.</param>
    public StaRuntimeShutdownException(string message)
        : base(message)
    {
    }
}
