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.)
Problem: 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.
Question: Is there a better more industry way of dealing with GUI Libraries other then using and implementing Events?
Goal: To create a reusable feature rich XNA Control Library implementing performance enhancing standards and so on.
Thank-you very much for taking your time to read this. I also hope this will help others possibly facing what I am facing right now.
UPDATE: LAG SOLVED. The lag was caused do to an update method in my base text control. I had a mistake of running a loop a ton of times when it did not need to be ran.
I have also remove all instances of EventArgs from the library as I personally see no point in them.