Denxorz.Latch 1.0.2

.NET 5.0 .NET Standard 2.0 .NET Framework 4.5.2
Install-Package Denxorz.Latch -Version 1.0.2
dotnet add package Denxorz.Latch --version 1.0.2
<PackageReference Include="Denxorz.Latch" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Denxorz.Latch --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Denxorz.Latch, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Denxorz.Latch as a Cake Addin
#addin nuget:?package=Denxorz.Latch&version=1.0.2

// Install Denxorz.Latch as a Cake Tool
#tool nuget:?package=Denxorz.Latch&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Latch

.Build status Coverage Status NuGet License

What does it do?

Latch makes sure that a piece of code is not executed when another piece of code is executing.

This package is based on the following articles:

Examples

// Remove the event handler for the moment
someComboBox.SelectedIndexChanged -= someHandler;

// do something that would probably make someComboBox fire the SelectedIndexChanged event

// Put the event handler back
someComboBox.SelectedIndexChanged += someHandler;

This example shows a common WinForms problem which can be solved with a latch.

// Declare the Latch as field: Latch someComboBoxLatch = new Latch();

someComboBoxLatch.RunInsideLatch(() =>
{
    // do something that would probably make someComboBox fire the SelectedIndexChanged event
});

Surrounding the critical code by the latch makes sure it is only executed once. Recursive calls and StackOverflows can be avoided.

// Declare the FullLatch as field: FullLatch someLatch = new FullLatch();

someLatch.LatchAndRun(() =>
{
    // do something and make sure the latch is set
});

someLatch.RunIfNotLatched(() =>
{
    // do something that should only run when not latched
});

This way you will have full control over the latch, and you can choose which parts latch and which parts are only run if not latched.

Tools and Products Used

Versions & Release Notes

version 1.0.2: Added .NET 5.0

version 1.0.1: Added .NET standard 2.0

version 1.0.0: First version (.NET Framework 4.5.2)

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 220 2/6/2021
1.0.1 401 4/5/2019
1.0.0 907 11/25/2016