Update-KrSynchronizedCounter

SYNOPSIS

Updates a synchronized counter in a thread-safe manner.

SYNTAX

__AllParameterSets

Update-KrSynchronizedCounter [-Table] <IDictionary> [-Key] <string> [[-By] <int>] [-WhatIf]
 [-Confirm] [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

This function updates a numeric counter stored in a synchronized collection (such as a synchronized Hashtable or OrderedDictionary) in a thread-safe way. It uses locking to ensure that increments are atomic and safe for concurrent access.

EXAMPLES

EXAMPLE 1

$table = [hashtable]::Synchronized(@{ Visits = 0 }) Update-KrSynchronizedCounter -Table $table -Key ‘Visits’ -By 1 This increments the ‘Visits’ counter in the synchronized hashtable by 1.

PARAMETERS

-By

The amount to increment the counter by. Default is 1.

Type: System.Int32
DefaultValue: 1
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 2
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Confirm

Prompts you for confirmation before running the command. The command is not run unless you respond affirmatively.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- cf
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Key

The key in the collection that identifies the counter to update.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Table

The synchronized collection (Hashtable or OrderedDictionary) containing the counter.

Type: System.Collections.IDictionary
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-WhatIf

Shows what would happen if the command runs. The command is not executed.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- wi
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

This function is part of the Kestrun.SharedState module and is used to safely update counters in shared state.

{{ Fill in the related links here }}