0
다른 응용 프로그램에서 사용할 클래스 라이브러리를 작성 중입니다. C# .NET에서 작성했습니다. 클래스 전체에서 이벤트를 트리거하는 데 문제가 있습니다. 여기에 내가해야 할 일입니다 ... 나는이 작업을 수행하는 클래스 라이브러리를 사용하는 응용 프로그램에서 다음 수업 전반에 걸친 일정을 어떻게 시작합니까?
public class ClassLibrary
{
public event EventHandler DeviceAttached;
public ClassLibrary()
{
// do some stuff
OtherClass.Start();
}
}
public class OtherClass : Form
{
public Start()
{
// do things here to initialize receiving messages
}
protected override void WndProc (ref message m)
{
if (....)
{
// THIS IS WHERE I WANT TO TRIGGER THE DEVICE ATTACHED EVENT IN ClassLibrary
// I can't seem to access the eventhandler here to trigger it.
// How do I do it?
}
base.WndProc(ref m);
}
}
...
public class ClientApplication
{
void main()
{
ClassLibrary myCL = new ClassLibrary();
myCL.DeviceAttached += new EventHandler(myCl_deviceAttached);
}
void myCl_deviceAttached(object sender, EventArgs e)
{
//do stuff...
}
}