Normally I would go:
bgwExportGrid.RunWorkerCompleted += ReportManager.RunWorkerCompleted;
The ReportManager class is a static class containing the event handler I want to use.
public static class ReportManager
{
public static void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
...
}
}
Now I have created a BackgroundWorker and want to attach the RunWorkerCompleted event as defined in ReportManager. However ReportManager cannot be referenced as otherwise a cyclic reference happens therefore reflection is needed.
Any help would be greatly appreciated.
I've looked at the following but haven't gotten very far:
Assembly assem = Utils.GetAssembly("WinUI.Reporting.Common.dll");
Type reportManagerType = assem.GetModule("WinUI.Reporting.Common.dll").GetType("WinUI.Reporting.Common.ReportManager");
EventInfo evWorkerCompleted = reportManagerType.GetEvent("RunWorkerCompleted");
Type tDelegate = evWorkerCompleted.EventHandlerType;