问题描述
我开发了需要处理的活饲料和广播的数据以pretty快速的方式监听器(约100纳秒级的精度,甚至比这更少,如果我能做到这一点)组件目前我从我的code引发事件,用户可以订阅。但是,由于其引发事件在同一线程上运行C#事件处理程序,我的线程这引起了直到所有用户处理完事件的事件将被阻止。我没有对用户的code控制,所以他们能做任何耗时在事件处理程序的操作,这可能会阻塞线程这是广播。
I am developing a component which needs to process the live feed and broadcast the data to the listeners in pretty fast manner ( with about 100 nano second level accuracy, even less than that if I can do that) Currently I am raising an event from my code which subscriber can subscribe to. However because in C# event handlers run on the same thread which raises the event, my thread which raises the event will be blocked until all subscribers finish processing the event. I do not have control on subscribers' code, so they can possibly do any time consuming operations in event handler, which may block the thread which is broadcasting.
我能做些什么,这样我可以广播数据给其他用户,但仍然可以播放的东西比较快??
What can I do so that I can broadcast the data to other subscribers but can still broadcast the stuff quite fast??
推荐答案
100纳秒是一个非常艰难的目标命中。我相信它会带你在做什么,为什么有深刻的理解,达到那样的表现。
100 ns is a very tough target to hit. I believe it will take a deep understanding of what you're doing and why to hit that kind of performance.
然而,异步调用事件订阅是pretty容易解决。
它已经回答给运行密封性能保证给用户。
edit:I should also mention that you need to be running on a real-time operating system to give tight performance guarantees to your users.
这篇关于在单独的线程中引发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!