事件处理事件处理乱序 [英] Event handler handling events out of order

查看:312
本文介绍了事件处理事件处理乱序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一台收音机微控制器(BLE)一些工作。在.NET中的 GenericAttributeProfile 命名空间支持的机制,是使用事件处理程序每当新的数据进来(通知)。我目前看到的一个问题是,尽管为了发送从无线电硬件我的数据,该数据不一定得到处理的顺序。我猜这是因为在调用事件处理程序异步的方式(请纠正我,如果我错了)。每一个新的数据块到来时,事件处理程序被调用,然后读取数据,并写入到控制台的数据和每递增事件处理函数(不是线程安全的时候一个静态变量,但似乎是OK用于​​测试)。该数据被打印出来,如果还递增,我可以看到,事件正在处理无序。

I'm doing some work with a radio microcontroller (BLE). The mechanism supported in .NET's GenericAttributeProfile namespace, is to use an EventHandler whenever new data comes in (notifications). A problem I'm currently seeing is that, despite my data being sent in order from the radio hardware, the data does not necessarily get dealt with in that order. I'm guessing this is due to the asynchronous manner in which the EventHandler is invoked (please correct me if I'm wrong). Every time a new piece of data comes in, the event handler is invoked, which then reads the data, and writes to console the data and a static variable which increments every time the event handler is called (not thread safe, but seems to be OK for testing). The data it is printing out if also incrementing, and I can see that the events are being handled out of order.

所以我的问题是,我该怎么办确保活动为了处理。从研究,我已经做了,我只能事件处理程序的执行顺序上找到的文献。我不关心,在这里,因为我只有1个事件处理程序。我关心的事件执行

So my question is, how do I ensure that events are handled in order. From the research I've done, I can only find literature on the order of eventHandler execution. I don't care about that here as I only have 1 eventHandler. I care about the order of event execution

推荐答案

更新2014年9月15日

我只想让大家知道,我其实是有2问题回事。我原本以为它与线程时间做但这只是问题的一部分(我反正)。之后,我定我的线程计时问题,我发现了,因为原来的海报曾表示,该事件实际上进来失灵。我已确认与微软的这个问题,他们现在正在努力解决这个问题。当我从他们那里得到了一项决议,我将它张贴在这里。

I just wanted to let everyone know that I actually had 2 issue going on. I had originally thought that it had to do with thread timing but that was only part of the problem (for me anyway). After I fixed my thread timing issue I found out, as the original poster had stated, the events are in fact coming in out of order. I have confirmed this issue with Microsoft and they are now working on a fix. As soon as I get a resolution from them I will post it here.

更新2015年1月8日

微软终于向我伸出手,并已确认该问题。然而,他们确定了成本效益太高添加到8.1核心,因此他们不会推出一个修复,直到窗口的下一个主要版本。

Microsoft has finally reached out to me and has confirmed the issue. However, they determined that the cost to benefit was too high to add to the 8.1 core so they won't introduce a fix until the next major release of windows.

这篇关于事件处理事件处理乱序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆