Xamarin NSMutableDictionary&;dispatch_async本机对象C#等效或类似

Xamarin NSMutableDictionary&;dispatch_async本机对象C#等效或类似,xamarin,xamarin.ios,Xamarin,Xamarin.ios,我对xamarin和移动开发还比较陌生。我目前正在通过Firebase将geofire库迁移到xamarin.ios。我遇到了下面的objective-c代码,并试图弄清楚到底在做什么?及其c#等价物: @property (nonatomic, strong) NSMutableDictionary *keyEnteredObservers; 对于callbackQueue,我目前使用类型BlockingCollectionANSMutableDictionary 它根据一个键过滤字典。

我对xamarin和移动开发还比较陌生。我目前正在通过Firebase将geofire库迁移到xamarin.ios。我遇到了下面的objective-c代码,并试图弄清楚到底在做什么?及其c#等价物:

@property (nonatomic, strong) NSMutableDictionary *keyEnteredObservers;


对于callbackQueue,我目前使用类型BlockingCollectionA
NSMutableDictionary

  • 它根据一个键过滤字典。(Linq
    ,其中
    将用作C#替换)

  • 字典的过滤元素可用于通过GCD(大中央调度)异步执行的“代码块”(
    dispatch\u async
    )。因此,您已经在使用
    BlockingCollection
    作为任务泵,因此将
    字符串作为参数传递给
    updateLocationInfo
    ,并将
    CLLocation
    传递给您的任务

注意:
stop
布尔值将导致提前退出枚举数,因此C#
中断
作为替换,但它不用于此上下文中

如果您仍在为您的观察者使用
NSMutableDictionary
,则可以通过
KeysForObject
进行过滤。在我的
GeoFire
版本中,我使用了
BlockingCollection
vs.Tasks,从而将lambda直接添加到工作队列中

比如:

foreach (var info in keyEnteredObservers.KeysForObject(firebaseHandle))
{
    var nonCapturedLocation = info.location.Copy(); // location = CLLocation, do not capture entire dictionary by ref in lambda
    callbackQueue.Add(() =>
    {
        GFQueryResultBlock(key, nonCapturedLocation);
    });
}

是的,我还在使用NSMutableDictionary,这正是我需要的。非常感谢。
foreach (var info in keyEnteredObservers.KeysForObject(firebaseHandle))
{
    var nonCapturedLocation = info.location.Copy(); // location = CLLocation, do not capture entire dictionary by ref in lambda
    callbackQueue.Add(() =>
    {
        GFQueryResultBlock(key, nonCapturedLocation);
    });
}