Created
June 1, 2025 05:03
-
-
Save ChuckBaggett/39acea6fe95d91cf5dde77fd3d714ddd to your computer and use it in GitHub Desktop.
program.cs from right code pane for jules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading; // Added | |
using System.Windows.Forms; // Ensure this is present for MessageBox | |
namespace TextToSpeechApp | |
{ | |
internal static class Program | |
{ | |
/// <summary> | |
/// The main entry point for the application. | |
/// </summary> | |
[STAThread] | |
static void Main() | |
{ | |
// Unique name for the Mutex. Using a GUID is a common way to ensure uniqueness. | |
const string appMutexName = "TextToSpeechApp_Mutex_C9A3F5E1-A5F8-4B2E-8D6F-7E3A0B4C1D7E"; | |
bool createdNew; | |
Mutex mutex = new Mutex(true, appMutexName, out createdNew); | |
if (!createdNew) | |
{ | |
// Another instance is already running. | |
MessageBox.Show("TextToSpeechApp is already running. Please close the existing instance.", | |
"Application Already Running", | |
MessageBoxButtons.OK, | |
MessageBoxIcon.Information); | |
return; // Exit the new instance | |
} | |
// To customize application configuration such as set high DPI settings or default font, | |
// see https://aka.ms/applicationconfiguration. | |
ApplicationConfiguration.Initialize(); // Or Application.EnableVisualStyles(); etc. | |
try | |
{ | |
Application.Run(new Form1()); | |
} | |
finally | |
{ | |
// Release the Mutex when the application exits. | |
// This is crucial if this instance was the one that created the Mutex. | |
mutex.ReleaseMutex(); | |
mutex.Dispose(); // Dispose the mutex object itself | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment