我如何订阅另一个大会中提出的事件 [英] how do I subscribe to an event in raised in another assembly
本文介绍了我如何订阅另一个大会中提出的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含3个项目的解决方案.一个项目处理异步通信.完成回调后,将引发事件SomethingCompleted. 如何在同一解决方案中从另一个项目订阅此事件?
I have a solution which contains 3 project. One project handles asynchronous communinications. When it has completed it's callback, it raises an event SomethingCompleted. How do I subscribe to this event from another project in the same solution?
我在接收项目中内置了事件处理程序,但是在发送项目中看不到该事件.
I have the event handlers built in the receiving project but it does not see the event in the sending project.
推荐答案
您需要引用引发事件的类以注册事件处理程序.
You need to have a reference to the class raising the event to register an event handler.
一旦有了它,就像注册其他任何事件处理程序一样:
Once you have that, it's done like registering any other event handler:
foo.SomethingCompleted += (sender, e) => this.DoSomething();
这篇关于我如何订阅另一个大会中提出的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文