madelson / DistributedLock

A .NET library for distributed synchronization
MIT License
1.85k stars 192 forks source link

EventWaitHandle support for local namespace #215

Open brad0000 opened 3 months ago

brad0000 commented 3 months ago

We're looking for a good, distributed locking library and yours looks good, except one of the things we want to do with it is use EventWaitHandles to signal between running copies of our app on a windows desktop, and as far as I can see your implementation only supports global locks which won't work for us.

Our app is deployed to law firms who often run user desktops on Citrix / Remote Desktop Servers and using global EventWaitHandles on those servers would cause the handle to be shared across user sessions. We instead need to use a non-global / local named EventWaitHandle that is scoped down to a single user's session.

Any appetite for supporting this scenario?

madelson commented 3 months ago

@brad0000 are you saying there’s a way to name the handles such that they have a scope broader than the current process but smaller than global? Any docs you can link me to on that?

If that’s the case, I’d be open to supporting it as an option. Any interest in contributing?

brad0000 commented 3 months ago

Yeah, the handles can always be used across thread and across process. Then depending on the name prefix (Global\, or Local\, or no prefix (defaults to local)) they're either scoped to the current user session or to the whole system. See "The name may be prefixed" here.

That said, we need to multicast a signal, which I think will require direct access to the set and reset methods, so we might need to the the EventWaitHandler directly.