Пример #1
0
        static void Something(string name, int delayInSeconds)
        {
            MutexMonopolizer mutexMonopolizer = new MutexMonopolizer(name, uniqueMutexName);

            mutexMonopolizer.OnlyMutexTesterRunning();

            Thread.Sleep(TimeSpan.FromSeconds(delayInSeconds));

            mutexMonopolizer.TryMonopoilzeMutex(TimeSpan.FromSeconds(5));
        }
Пример #2
0
        static void Main(string[] args)
        {
            using (MutexMonopolizer mutexTester = new MutexMonopolizer(SetMutexTesterName(args), uniqueMutexName))
            {
                mutexTester.OnlyMutexTesterRunning();

                Console.WriteLine("Please specify in seconds how long you want to get the mutex signal for...");

                string input = string.Empty;

                while (input != "quit" && input != "q")
                {
                    input = Console.ReadLine();

                    int seconds;
                    bool isNumber = int.TryParse(input, out seconds);

                    if (isNumber)
                    {
                        mutexTester.TryMonopoilzeMutex(TimeSpan.FromSeconds(seconds));
                    }
                }
            }
        }