From Xojo Documentation

Revision as of 18:55, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


A type of CriticalSection that has operating system-wide scope and is visible to other REALbasic applications.

Super Class



Name Parameters Description
Mutex Name as String The parameter is the name of the Mutex.

If you pass an empty string, the Mutex will be identical to a CriticalSection; it will not be visible to other applications. If you pass a name, you can use the name to access the Mutex.


Mutex is short for Mutual Exclusion object. It allows several applications to share the same resource, but not simultaneously. The suggested usage of a Mutex is to create a Mutex with a unique name when the application launches. When the application needs to use the resource, it calls the Enter or TryEnter methods and calls the Leave method when it is finished. The most common use of a Mutex is to determine whether another instance of your application is currently running. You create a named Mutex in the application's open event and then check to see if you can get a lock on it. If the lock fails, then you know there's another instance of your application running. You can also use Mutexes to work with resources that are shared between applications (such as a serial port, printer, or some other system device).

You can call Enter or TryEnter multiple times in the same way as with a CriticalSection, including recursive calls.

See Also

Application, CriticalSection, Semaphore, Thread classes.