Skip to content

Provide a way to verify which thread owns a lock #102621

Open
@vsfeedback

Description

This issue has been moved from a ticket on Developer Community.


On the new Lock Class introduced on .NET 9.0 preview, we have a property (IsHeldByCurrentThread) that allows us to check whether the lock is being held by the current thread or not: https://learn.microsoft.com/en-us/dotnet/api/system.threading.lock?view=net-9.0

However, if a lock is being hold by a different thread, it becomes difficult to determine which thread holds the lock. I understand that this isn't impossible to achieve, since Win32's critical section has an internal member that tells the user that information.

Having this supposed new property that tells us the current Id of the thread that's holding the lock could make software engineer's lives easier, as it would improve traceability when debugging code.


Original Comments

Feedback Bot on 5/10/2024, 10:36 PM:

(private comment, text removed)

Activity

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

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions