并行事件处理程序 [英] Parallel EventHandler

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

问题描述

我要毫不迟延地通知我班的活动用户,同时

I want to notify my class's event subscribers without delay and simultaneously.

我应该推出自己的事件处理程序;使用一些从FCL支持并行机制;或默认内置的 System.EventHandler< T> 支持事件通知等方式

Should I roll my own event handler; use some from FCL supporting parallelism; or default built-in System.EventHandler<T> support such way of event notification?

推荐答案

您可以使用 MulticastDelegate.GetInvocationList 任何代表,然后只调用所有组件代表并行。这可能是最容易的方式。

You can use MulticastDelegate.GetInvocationList for any delegate, and then just invoke all of the component delegates in parallel. That's probably the easiest way to go.

(它返回委派[] ,但你可以施展每个实例的。正确的类型你可能甚至铸造阵列本身脱身 - 我不记得到底是什么类型的数组它的真正的创建)

(It returns Delegate[] but you can cast each instance to the right type. You may even get away with casting the array itself - I can't remember exactly what kind of array it actually creates.)

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

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