Skip to content

Mutex in C#: .NET 10, async pitfall demo, ownership tests - #2333

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/94885-csharp-how-to-use-mutex-class
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/94885-csharp-how-to-use-mutex-class

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Moves the MutexClassInCSharp sample from net7.0 to net10.0 and updates the test packages (xunit 2.9.3, xunit.runner.visualstudio 4.0.1, Microsoft.NET.Test.Sdk 18.11.0, coverlet.collector 10.1.0). Adds MutexAsyncPitfall, which shows ReleaseMutex failing after an await resumes on another thread, behind a new --async-pitfall switch in Program.Main (any other argument runs the original file-writing demo unchanged), and two tests that pin the ownership rules: an abandoned Mutex throws AbandonedMutexException on the next WaitOne and leaves that thread as owner, and a non-owner thread gets ApplicationException from ReleaseMutex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant