事件处理程序执行顺序 [英] Order of event handler execution

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

问题描述

如果我设置多个事件处理程序,如下所示:

If I set up multiple event handlers, like so:

_webservice.RetrieveDataCompleted += ProcessData1;
_webservice.RetrieveDataCompleted += ProcessData2;

当事件 RetrieveDataCompleted 被触发时,处理程序的运行顺序是什么?它们是否在同一个线程中按照注册的顺序依次运行?

what order are the handlers run when the event RetrieveDataCompleted is fired? Are they run in the same thread and sequentially in the order that are registered?

推荐答案

目前,它们是按照注册的顺序执行的.但是,这是一个实现细节,我不会依赖这种行为在未来版本中保持不变,因为规范不需要它.

Currently, they are executed in the order they are registered. However, this is an implementation detail, and I would not rely on this behavior staying the same in future versions, since it is not required by specifications.

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

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