SGU.Tools_MessageBoxTimed 3.6.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package SGU.Tools_MessageBoxTimed --version 3.6.4
                    
NuGet\Install-Package SGU.Tools_MessageBoxTimed -Version 3.6.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SGU.Tools_MessageBoxTimed" Version="3.6.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SGU.Tools_MessageBoxTimed" Version="3.6.4" />
                    
Directory.Packages.props
<PackageReference Include="SGU.Tools_MessageBoxTimed" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SGU.Tools_MessageBoxTimed --version 3.6.4
                    
#r "nuget: SGU.Tools_MessageBoxTimed, 3.6.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SGU.Tools_MessageBoxTimed@3.6.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SGU.Tools_MessageBoxTimed&version=3.6.4
                    
Install as a Cake Addin
#tool nuget:?package=SGU.Tools_MessageBoxTimed&version=3.6.4
                    
Install as a Cake Tool

MessageBoxTimed

Buy Me A Coffee

A Windows Forms message box that automatically closes after a specified timeout period with optional countdown display.

NuGet Version

Features

  • ✅ Auto-close message boxes after a specified timeout
  • ✅ Optional countdown timer display on buttons
  • Full MessageBox.Show API compatibility - Drop-in replacement with timeout functionality
  • ✅ Support for all MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton, and MessageBoxOptions
  • ✅ Factory pattern for reusable message box configurations
  • ✅ Thread-safe implementation
  • ✅ Multi-target support (.NET Framework 4.8 through .NET 10)

Installation

Install via NuGet Package Manager Console:

Install-Package SGU.Tools_MessageBoxTimed

Or via .NET CLI:

dotnet add package SGU.Tools_MessageBoxTimed

Usage

Basic Usage

using SGU.Tools;

// Simple auto-closing message box (closes after 1000ms by default) 
MessageBoxTimed.Show("Operation completed successfully!");

With Timeout and Buttons

// Wait for user input or auto-close with default result 
var result = MessageBoxTimed.Show(
    text: "Save changes before closing?",
    caption: "Confirm",
    timeout: 5000,
    buttons: MessageBoxButtons.YesNoCancel,
    defaultResult: DialogResult.Cancel
);

With Icons

// Display with standard Windows icons
MessageBoxTimed.Show(
    text: "File saved successfully!",
    caption: "Success",
    timeout: 3000,
    buttons: MessageBoxButtons.OK,
    icon: MessageBoxIcon.Information
);

// Warning message
MessageBoxTimed.Show(
    text: "This action cannot be undone!",
    caption: "Warning",
    timeout: 5000,
    buttons: MessageBoxButtons.OKCancel,
    icon: MessageBoxIcon.Warning
);

With Default Button

// Set which button is focused by default
MessageBoxTimed.Show(
    text: "Delete this item?",
    caption: "Confirm Delete",
    timeout: 10000,
    buttons: MessageBoxButtons.YesNo,
    icon: MessageBoxIcon.Question,
    defaultButton: MessageBoxDefaultButton.Button2  // "No" is default
);

With MessageBoxOptions (RTL, etc.)

// Right-to-left reading for localization
MessageBoxTimed.Show(
    text: "مرحبا بك في التطبيق",
    caption: "ترحيب",
    timeout: 5000,
    buttons: MessageBoxButtons.OK,
    icon: MessageBoxIcon.Information,
    defaultButton: MessageBoxDefaultButton.Button1,
    options: MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign
);

With Countdown Display

// Show countdown timer on the default button 
MessageBoxTimed.Show(
    text: "This will close automatically...",
    caption: "Auto-Close Demo",
    timeout: 5000,
    buttons: MessageBoxButtons.OK,
    icon: MessageBoxIcon.Information,
    showCountDown: true
);

With Owner Window

// Display as modal to a specific window 
MessageBoxTimed.Show(
    owner: this,
    text: "Processing complete!",
    caption: "Success",
    timeout: 3000,
    buttons: MessageBoxButtons.OK,
    icon: MessageBoxIcon.Information
);

Factory Pattern

// Create reusable message box configuration (basic)
var infoDialog = MessageBoxTimed.Factory(
    showMethod: (caption, buttons) => MessageBox.Show(
        "Operation completed", 
        caption, 
        buttons
    ),
    caption: "Information"
);

// Create factory with icon support
var confirmDialog = MessageBoxTimed.FactoryWithIcon(
    showMethod: (caption, buttons, icon) => MessageBox.Show(
        this, 
        "Are you sure?", 
        caption, 
        buttons, 
        icon
    ),
    caption: "Confirmation Required",
    showCountDown: true
);

// Create factory with full MessageBox.Show compatibility
var fullDialog = MessageBoxTimed.FactoryFull(
    showMethod: (caption, buttons, icon, defaultButton, options) => 
        MessageBox.Show(
            this,
            "Custom message",
            caption,
            buttons,
            icon,
            defaultButton,
            options
        ),
    caption: "My Application"
);

// Use the factory instances
var result = confirmDialog.Show(
    timeout: 10000,
    buttons: MessageBoxButtons.YesNo,
    icon: MessageBoxIcon.Question,
    defaultResult: DialogResult.No
);

var fullResult = fullDialog.Show(
    timeout: 5000,
    buttons: MessageBoxButtons.YesNo,
    icon: MessageBoxIcon.Warning,
    defaultButton: MessageBoxDefaultButton.Button2,
    options: MessageBoxOptions.DefaultDesktopOnly
);

API Reference

MessageBoxTimed.Show() Overloads

Basic Overload
DialogResult Show(
    string text,
    string caption = null,
    int timeout = 1000,
    MessageBoxButtons buttons = MessageBoxButtons.OK,
    DialogResult defaultResult = DialogResult.None,
    bool showCountDown = false
)
With Icon
DialogResult Show(
    string text,
    string caption,
    int timeout,
    MessageBoxButtons buttons,
    MessageBoxIcon icon,
    DialogResult defaultResult = DialogResult.None,
    bool showCountDown = false
)
With Default Button
DialogResult Show(
    string text,
    string caption,
    int timeout,
    MessageBoxButtons buttons,
    MessageBoxIcon icon,
    MessageBoxDefaultButton defaultButton,
    DialogResult defaultResult = DialogResult.None,
    bool showCountDown = false
)
With Options (Full Compatibility)
DialogResult Show(
    string text,
    string caption,
    int timeout,
    MessageBoxButtons buttons,
    MessageBoxIcon icon,
    MessageBoxDefaultButton defaultButton,
    MessageBoxOptions options,
    DialogResult defaultResult = DialogResult.None,
    bool showCountDown = false
)
With Owner Window

All of the above overloads also have variants that accept an IWin32Window owner as the first parameter.

Parameters

Parameter Type Default Description
owner IWin32Window - Parent window for modal display
text string - The message text to display
caption string null The title bar text
timeout int 1000 Timeout in milliseconds
buttons MessageBoxButtons OK Buttons to display (OK, OKCancel, YesNo, etc.)
icon MessageBoxIcon None Icon to display (None, Information, Warning, Error, Question)
defaultButton MessageBoxDefaultButton Button1 Which button has focus by default
options MessageBoxOptions 0 Display options (RtlReading, RightAlign, etc.)
defaultResult DialogResult None Result when timeout expires
showCountDown bool false Show countdown timer on button

Factory Methods

MessageBoxTimed.Factory()
IMessageBoxTimed Factory(
    Func<string, MessageBoxButtons, DialogResult> showMethod,
    string caption = null,
    bool showCountDown = false
)

Creates a reusable factory with basic MessageBox functionality.

MessageBoxTimed.FactoryWithIcon()
IMessageBoxTimed FactoryWithIcon(
    Func<string, MessageBoxButtons, MessageBoxIcon, DialogResult> showMethod,
    string caption = null,
    bool showCountDown = false
)

Creates a reusable factory with icon support.

MessageBoxTimed.FactoryFull()
IMessageBoxTimed FactoryFull(
    Func<string, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton, MessageBoxOptions, DialogResult> showMethod,
    string caption = null,
    bool showCountDown = false
)

Creates a reusable factory with full MessageBox.Show compatibility.

IMessageBoxTimed Interface

public interface IMessageBoxTimed
{
    DialogResult Show(
        int timeout = 1000,
        MessageBoxButtons buttons = MessageBoxButtons.OK,
        DialogResult defaultResult = DialogResult.None
    );

    DialogResult Show(
        int timeout,
        MessageBoxButtons buttons,
        MessageBoxIcon icon,
        DialogResult defaultResult = DialogResult.None
    );

    DialogResult Show(
        int timeout,
        MessageBoxButtons buttons,
        MessageBoxIcon icon,
        MessageBoxDefaultButton defaultButton,
        DialogResult defaultResult = DialogResult.None
    );

    DialogResult Show(
        int timeout,
        MessageBoxButtons buttons,
        MessageBoxIcon icon,
        MessageBoxDefaultButton defaultButton,
        MessageBoxOptions options,
        DialogResult defaultResult = DialogResult.None
    );
}

Platform Support

  • .NET Framework 4.8 (Windows)
  • .NET 6.0 (Windows)
  • .NET 8.0 (Windows)
  • .NET 10.0 (Windows)
  • Requires Windows OS (uses Win32 APIs)

Compatibility

MessageBoxTimed is designed as a drop-in replacement for the standard MessageBox.Show. All standard MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton, and MessageBoxOptions are supported, plus the additional timeout and countdown features.

Migration from MessageBox.Show

Simply replace your MessageBox.Show calls with MessageBoxTimed.Show and add timeout parameters:

// Before
var result = MessageBox.Show(
    "Delete this file?",
    "Confirm",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question
);

// After - with 10 second auto-close
var result = MessageBoxTimed.Show(
    "Delete this file?",
    "Confirm",
    10000,  // 10 seconds
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    defaultResult: DialogResult.No
);

Issue Reporting

If you encounter any issues or have feature requests, please report them on the GitHub Issues page for this repository.

License

Licensed under the MIT License.

Author

Solutions Group Unlimited, LLC

Copyright © 2025 Solutions Group Unlimited, LLC. All rights reserved.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net10.0-windows7.0

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.7.1 89 1/14/2026
3.6.4 94 1/8/2026
3.5.28 93 12/30/2025
3.5.26 88 12/30/2025