本文介绍了在.NET Compact Framework受信号灯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,在使用.NET Compact Framework的时候是没有信号灯中的System.Threading。我不知道这是为什么,没有任何人有一个想法?

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

谷歌上搜索,我发现了一堆人给自己的实现,但没有人真正伟大的工作......或在所有后!

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

所以,我特地请专家...

So I've come to ask the experts...

有没有人有一个良好的信号类/库,他们可以推荐为.NET紧凑框架是什么?

Does anyone have a good semaphore class/library they can recommend for the .NET compactframework?

有好歹我可以模仿的行为?

Is there someway I can emulate the behaviour?

我有一个典型的生产者/消费者设置在一个线程到一个队列(System.Collections中)推对象。那么我想一个消费者线程拉断队列对象和做的工作,但很明显,只有当有东西在排队!工作

I have a typical producer/consumer setup in which a thread pushes objects on to a Queue (System.Collections).I then want a consumer thread to pull objects off the queue and do work, but obviously only when there are things on the queue to work with!

我的工作在C#中,但我会采取的解决方案/伪的任何语言​​,只要我能在.NET CF实现它。

I am working in C#, but I'll take solutions/pseudo in any language so long as I can implement it on .NET CF.

推荐答案

您可以直接的PInvoke到CreateSemaphore和ReleaseSemaphore-他们对行政长官的coredll实施。 pretty的易写一个很好的托管包装,看起来像System.Threading.Semaphore。

You can just PInvoke to CreateSemaphore and ReleaseSemaphore- they're implemented on CE in coredll. Pretty easy to write a nice managed wrapper that looks like System.Threading.Semaphore.

这篇关于在.NET Compact Framework受信号灯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 08:31