简体   繁体   English

从dll到Winform应用程序的通知

[英]Notification from the dll to the winform application

I have created a C# project , and using it's dll as a reference in another Winform application and calling the functions present in the dll project. 我创建了一个C#项目,并利用它的DLL在另一个WinForm应用程序的引用,并调用存在于dll项目的功能。

I have a requirement that , I have to call a winform's function from that dll. 我有一个要求,我必须从该dll调用winform的函数。 Is there any way I can register a function to my dll ? 有什么办法可以向我的dll注册功能? Or any other way I am able to notify the winform application from the dll , in some condition ? 或者,我可以从DLL通知WinForm应用程序,在一定条件下的任何其他方式?

I just want to send a kind of notification from the dll to the winform application . 我只想从dll向Winform应用程序发送一种通知。

I will be using WCF to wrap-up the dll project .(any help ?) 我将使用WCF打包dll项目。(有帮助吗?)

Ideas/Code samples will be much helpful. 想法/代码示例将很有帮助。

The mechanism used by c# for this purpose is called an event . c#为此目的使用的机制称为event

You will define this event inside your dll project. 您将在dll项目中定义此事件。 Your Winforms project will register to this event, and it will run a method each time the event is fired from the dll. 您的Winforms项目将注册到此事件,并且每次从dll触发该事件时,它将运行一个方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM