ktsu.SingleAppInstance
0.0.1-pre.1
Prefix Reserved
See the version list below for details.
dotnet add package ktsu.SingleAppInstance --version 0.0.1-pre.1
NuGet\Install-Package ktsu.SingleAppInstance -Version 0.0.1-pre.1
<PackageReference Include="ktsu.SingleAppInstance" Version="0.0.1-pre.1" />
paket add ktsu.SingleAppInstance --version 0.0.1-pre.1
#r "nuget: ktsu.SingleAppInstance, 0.0.1-pre.1"
// Install ktsu.SingleAppInstance as a Cake Addin #addin nuget:?package=ktsu.SingleAppInstance&version=0.0.1-pre.1&prerelease // Install ktsu.SingleAppInstance as a Cake Tool #tool nuget:?package=ktsu.SingleAppInstance&version=0.0.1-pre.1&prerelease
ktsu.SingleAppInstance
Overview
The SingleAppInstance
class provides a mechanism to ensure that only one instance of an application is running at a time. This is useful for applications that should not have multiple instances running simultaneously, such as desktop applications or services.
Features
- Single Instance Enforcement: Ensures that only one instance of the application is running.
- PID File Management: Uses a PID file to track the running instance.
- Race Condition Handling: Handles potential race conditions when starting multiple instances simultaneously.
Installation
To install the ktsu.SingleAppInstance
package, run the following command in a console:
dotnet add package ktsu.SingleAppInstance
Getting Started
To get started with ktsu.SingleAppInstance
, follow these steps:
- Install the package using the command above.
- Add the necessary
using
directive to your code. - Call the
ExitIfAlreadyRunning
method at the start of your application.
Usage
To use the SingleAppInstance
class, call the ExitIfAlreadyRunning
method at the start of your application. This method will check if another instance is already running and exit the current instance if so.
using ktsu.SingleAppInstance;
class Program
{
static void Main(string[] args)
{
SingleAppInstance.ExitIfAlreadyRunning();
// Your application code here
}
}
Or if you prefer to explicitly handle the case where another instance is already running, you can call the ShouldLaunch()
method to check if another instance is running.
using ktsu.SingleAppInstance;
class Program
{
static void Main(string[] args)
{
if (SingleAppInstance.ShouldLaunch())
{
// Your application code here
}
else
{
// Handle the case where another instance is already running
Console.WriteLine("Another instance is already running.");
Environment.Exit(1);
}
}
}
Methods
ExitIfAlreadyRunning
Exits the application if another instance is already running.
ShouldLaunch
Determines whether the application should launch.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Support
If you encounter any issues or have questions, please open an issue on GitHub.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- ktsu.AppDataStorage (>= 1.4.7)
-
net9.0
- ktsu.AppDataStorage (>= 1.4.7)
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 |
---|---|---|
1.0.0-pre.4 | 27 | 1/18/2025 |
1.0.0-pre.3 | 32 | 1/16/2025 |
1.0.0-pre.2 | 5 | 1/14/2025 |
1.0.0-pre.1 | 36 | 1/13/2025 |
0.0.1-pre.1 | 29 | 1/13/2025 |
## v1.0.0-pre.1 (major)
Changes since 0.0.0.0:
- Initial commit ([@matt-edmondson](https://github.com/matt-edmondson))