Mutex.Create
------------

Creates a new mutex with given name.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Mutex](component_Mutex.md) | [10.2](newinversion102.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Mutex.Create"; Name ) 

**MBS**( **"Mutex.Create";** /\* Creates a new mutex with given name. \*/  
**$Name**) /\* The name to use for the mutex.  
Name should be a simple text, but unique, so we recommend reverse domain notation.  
The name should not contain a slash.e.g. "test" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Name | The name to use for the mutex.   Name should be a simple text, but unique, so we recommend reverse domain notation.   The name should not contain a slash. | "test" |

### Result

Returns reference number or error.

### Description

Creates a new mutex with given name.  
If mutex exists already, we open it. The mutex lives until the last application closed it.  
Please call [Mutex.Release](MutexRelease.md) later.  
  
If name matches the name of an existing event, semaphore, waitable timer, job, or file-mapping object, the function fails.  
You can open the same mutex twice and get different reference numbers from the plugin.  
### Examples

Create a mutex

 MBS ( "Mutex.Create"; "com.monkeybreadsoftware.test" )  
Create the mutex and use it:

 # create a mutex   
Set Variable \[ $mutex ; Value: MBS ( "Mutex.Create"; "de.monkeybreadsoftware.test" ) \]   
\# lock it   
Set Variable \[ $r ; Value: MBS ( "[Mutex.TryLock](MutexTryLock.md)"; $Mutex ) \]   
If \[ $r = 1 \]   
 # do something  
 #   
 # finally unlock  
 Set Variable \[ $r ; Value: MBS ( "[Mutex.Unlock](MutexUnlock.md)"; $Mutex ) \]   
End If  
\# free it mutex   
Set Variable \[ $r ; Value: MBS ( "[Mutex.Release](MutexRelease.md)"; $Mutex ) \]  
### See also

- [Mutex.Release](MutexRelease.md)
- [Mutex.TryLock](MutexTryLock.md)
- [Mutex.Unlock](MutexUnlock.md)

### Blog Entries

- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 5th April 2020 , last changed 29th May 2024

  
[Msgbox](Msgbox.md) - [Mutex.GetTag](MutexGetTag.md)

[HTML Version](MutexCreate.shtml)