How do I pass an object reference to a controller in MVC?
I am trying to make better use of MVC / MVP style patterns with my WinForm applications and I am afraid what might be with someone with more experience might help me.
Below is my main project:
The class G2.cs
handles the execution of various threads and includes Start / Stop and other various methods associated with those threads. I think this is my "main" class. It also contains the main loop for my application.
My GUI has three forms and a corresponding controller for each. The button MainForm
has Start / Stop buttons that should call methods in my class G2
, as well as possible future forms.
What would be the correct way to pass the reference of my G2 class to all view controllers that need it? Do I need to pass a link G2
to the form when I create it and the form in turn passes it to my controllers or ... is this not a good way to handle things?
Also, am I correcting that the responsibility for instantiating this controller and its controller "owner" is the responsibility of Views?