Created
December 27, 2020 12:58
-
-
Save ierhalim/c251aba6a76ac1b928cce0d85d646c03 to your computer and use it in GitHub Desktop.
Y207 Paralel programlama
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; | |
| 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