Skip to content

Instantly share code, notes, and snippets.

@ierhalim
Created December 27, 2020 12:58
Show Gist options
  • Select an option

  • Save ierhalim/c251aba6a76ac1b928cce0d85d646c03 to your computer and use it in GitHub Desktop.

Select an option

Save ierhalim/c251aba6a76ac1b928cce0d85d646c03 to your computer and use it in GitHub Desktop.
Y207 Paralel programlama
using System;
using System.Threading;
namespace DataSharing
{
class Program
{
const string appName = "ExampleApp";
static void Main(string[] args)
{
Mutex appMutex;
bool enableToRun = false;
try
{
Mutex.OpenExisting(appName);
}
catch (WaitHandleCannotBeOpenedException)
{
enableToRun = true;
appMutex = new Mutex(false, appName);
}
if (!enableToRun)
{
Console.WriteLine("{0} is running in another window.", appName);
Console.ReadKey();
}
else
{
Console.WriteLine("Program...");
// Logic.
Console.ReadKey();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment