Language: C# w/ XNA Framework
Relevant and hopefully helpful background info:
I am making a library using the XNA framework for games I make with XNA. The Library has a folder(Namespace) dedication to the GUI. The GUI Controls inherit a base class hooked with the appropriate Interfaces. After a control is made, the programmer can hook the control with a "Frame" or "Module" that will tell the controls when to update and draw with an event. To make a "Frame" or "Module", you would inherit a class with the details coded in. (Kind of how win forms does it.) My reason for doing this is to simplify the process of creating menus with intractable controls. The only way I could think of for making the events for all the controls to function without being class specific would be to typecast a control to an object and typecast it back. (As I have read, this can be terribly inefficient.)
Unfortunately, after I have implemented interfaces into the base classes and changed
public delegate void ClickedHandler(BaseControl cntrl);
public delegate void ClickedHandler(Object cntrl, EventArgs e);
my game has decreased in performance. This performance could be how I am firing the events, as what happens is the one menu will start fine, but then slowly but surely will freeze up. Every other frame works just fine, I just think it has something to do with the events and... that is why I am asking about them.
Is there a better more industry way of dealing with GUI Libraries other than using and implementing Events?
To create a reusable feature rich XNA Control Library implementing performance enhancing standards and so on.