# Invoke-BluGenieThreadLock

﻿

### Invoke-BluGenieThreadLock <a href="#invoke-blugeniethreadlock" id="invoke-blugeniethreadlock"></a>

### SYNOPSIS <a href="#synopsis" id="synopsis"></a>

Create a named Mutex

### SYNTAX <a href="#syntax" id="syntax"></a>

```
Invoke-BluGenieThreadLock [-ShowLocks] [-Walkthrough] [<CommonParameters>]

Invoke-BluGenieThreadLock [-setLock] [[-lockName] <String>] [-timeOut <Int32>] [-GlobalName <String>] [-Walkthrough] [<CommonParameters>]

Invoke-BluGenieThreadLock [-releaseLock] [[-lockName] <String>] [-timeOut <Int32>] [-GlobalName <String>] [-Walkthrough] [<CommonParameters>]
```

### DESCRIPTION <a href="#description" id="description"></a>

With a named mutex, we can specify a mutex with a name on one process and then tell it to take the mutex and on another process (yes, another PowerShell console would work) and call the same named mutex and if we attempt to take the mutex, it will create a blocking call until the other process relinquishes control of it. What this allows us to do is have multiple processes that can write to a single file without fear of missing data due to the file being locked.

### EXAMPLES <a href="#examples" id="examples"></a>

#### EXAMPLE 1 <a href="#example-1" id="example-1"></a>

```
Command: $mtx = Invoke-BluGenieMutux -Name Log
```

```
$mtx.WaitOne()
           'other important data' | Out-File C:\importantlogfile.txt -Append
           $mtx.ReleaseMutex()Description: Create Mutux Threading to lock Logging file.
Notes: 

..EXAMPLE
Command: $mtx = Invoke-BluGenieMutux -Name Log
           $mtx.WaitOne(1000)
           'other important data' | Out-File C:\importantlogfile.txt -Append
           $mtx.ReleaseMutex()Description: Create Mutux Threading with a 1000 second timeout.
Notes:
```

#### EXAMPLE 2 <a href="#example-2" id="example-2"></a>

```
-Help
```

```
Description: Call Help Information
Notes: If Help / WalkThrough is setup as a parameter, this script will be called to setup the Dynamic Help Menu if not the normal Get-Help will be called with the -Full parameter
```

#### EXAMPLE 3 <a href="#example-3" id="example-3"></a>

```
-WalkThrough
```

```
Description: Call Help Information [2]
Notes: If Help / WalkThrough is setup as a parameter, this script will be called to setup the Dynamic Help Menu if not the normal Get-Help will be called with the -Full parameter
```

### PARAMETERS <a href="#parameters" id="parameters"></a>

#### setLock <a href="#setlock" id="setlock"></a>

```
-setLock [<SwitchParameter>]
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### releaseLock <a href="#releaselock" id="releaselock"></a>

```
-releaseLock [<SwitchParameter>]
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### lockName <a href="#lockname" id="lockname"></a>

```
-lockName <String>
   
   Required?                    false
   Position?                    2
   Default value                ThreadLock
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### timeOut <a href="#timeout" id="timeout"></a>

```
-timeOut <Int32>
   
   Required?                    false
   Position?                    named
   Default value                600
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### GlobalName <a href="#globalname" id="globalname"></a>

```
-GlobalName <String>
   
   Required?                    false
   Position?                    named
   Default value                MyLock
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### ShowLocks <a href="#showlocks" id="showlocks"></a>

```
-ShowLocks [<SwitchParameter>]
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### Walkthrough <a href="#walkthrough" id="walkthrough"></a>

```
-Walkthrough [<SwitchParameter>]
   Description:  Start the dynamic help menu system to help walk through the current command and all of the parameters
   Notes:  
   Alias: Help
   ValidateSet:
   
   Required?                    false
   Position?                    named
   Default value                False
   Accept pipeline input?       false
   Accept wildcard characters?  false
```

#### CommonParameters <a href="#commonparameters" id="commonparameters"></a>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manuals.blusapphire.io/blugenie/full-function-list/invoke-blugeniethreadlock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
