简体   繁体   中英

Fire DLL event from another DLL (or Application)

I have 2 projects. In the first:

public delegate _Event(int code);
public event _Event TestEvent;

now I want to do something like this in my second project

public void TestFunc()
{
   TestEvent(11); //Project1.MyClass.TestEvent(11);
}

namely I want to fire Project1's event form Project2. Can anybody help me about this?

1.You're missing the return type on the delegate.

2.You can fire the event from within the declaring type only. What you can do is declare a public method on the type which declares the event which fires it.

public delegate void _Event(int code);
public event _Event TestEvent;
public void FireEvent(int val){TestEvent(val);}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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