Skip to content

Instantly share code, notes, and snippets.

View brendankowitz's full-sized avatar

Brendan Kowitz brendankowitz

View GitHub Profile
@brendankowitz
brendankowitz / CancellableSemaphore.cs
Last active January 24, 2024 11:24
What is a good pattern for Awaiting Semaphores with a CancellationToken?
/// <summary>
/// Allows a semaphore to release with the IDisposable pattern
/// </summary>
/// <remarks>
/// Solves an issue where using the pattern:
/// <code>
/// try { await sem.WaitAsync(cancellationToken); }
/// finally { sem.Release(); }
/// </code>
/// Can result in SemaphoreFullException if the token is cancelled and the
@brendankowitz
brendankowitz / UnitTestFhirNet19.cs
Created November 20, 2020 15:07
Extension differences
using System;
using System.Linq;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
using Xunit;
namespace TestProject1
{
public class UnitTest1