Semaphores in the .NET compact framework

Unfortunately, Semaphore in System.Threading when using the .NET Compact Framework is missing. I'm not sure why this is so, does anyone have an idea?

After googling, I found a bunch of people giving their own implementations, but none of them worked perfectly ... or at all!

So, I came to ask the experts ...

Does anyone have a good semaphore class / library that they can recommend for a .NET compact framework?

OR

Is there any way to emulate behavior?

I have a typical producer / consumer setting in which a thread queues objects (System.Collections). Then I want the consumer stream to pull objects out of the queue and do the work, but obviously only when things work in the queue!

I work in C #, but I will make decisions / pseudo in any language, as long as I can implement it in .NET CF.

+3
source share
2 answers

You can just PInvoke for CreateSemaphore and ReleaseSemaphore - they are implemented on CE in coredll. It's pretty easy to write a beautiful managed shell similar to System.Threading.Semaphore.

+4
source

I think there is a semaphore implementation in OpenNETCF

+2
source

Source: https://habr.com/ru/post/1723069/


All Articles