Mono.Unix.FileMutex.Release C# (CSharp) Method

Release() public method

public Release ( ) : void
return void
        public void Release()
        {
            lock (typeof(FileMutex))
            {
                if (handle > 0)
                {
                    // a write (exclusive) unlock
                    wl.l_type = LockType.F_UNLCK;
                    Syscall.fcntl(handle, FcntlCommand.F_SETLKW, ref wl);
                }
            }
        }
    }

Usage Example

Beispiel #1
0
        static void __Main(string[] args)
        {
            string file = @"/home/user/Desktop/lock2";

            FileMutex mutex = new FileMutex(file);

            Console.WriteLine("Trying to obtain exclusive lock...");

            mutex.Wait(1000 * 5);
            Console.WriteLine("exclusive lock is obtained...");

            Console.WriteLine("Press 'Enter' to release lock.");
            Console.ReadLine();

            mutex.Release();
            Console.WriteLine("Lock is released.");

            Console.ReadLine();
            Console.WriteLine("Press 'Enter' to exit.");
        }
All Usage Examples Of Mono.Unix.FileMutex::Release