I have a winforms applications which should be able to communicate with a custom device. I have a main window which has a button "Disconnect". I have a user control which handles the logging, and a class (SerialCom) which handles all communciation.
When I load the user control I also setup the com port in the SerialCom class. This class receives data, and sends it to the user control via INotifyPropertyChanged, see this question for more detail here.
I want to acces the class SerialCom from the MainForm, without having to new the SerialCom class. but the SerialCom class is first created on the user control. (so, if I new the SerialCom class from the MainForm, the serial port will not be open, so I cannot close it.)
Any tips on how to acces class A from class B and C without having to new class A again? I was thinking about passing the event between the forms, is this the best option?
SerialComa singleton?