Best way to link mulitple objects?

Deeko

Lifer
Jun 16, 2000
30,213
12
81
Ok, I've got a main program, that acts simply as a container to hold three objects...two forms(both which interact with the user, and a controller, which interacts with the forms & with some hardware. All three objects need two way communication with each other. Initially, I thought I would set the controller up as an observer, and the forms as observable, but with two way communication, I'd need all of them to be both observers and observable, which doesn't really seem like good style. I then thought I could make custom event handlers, have each object hold a command queue, and trigger an event in the main program whenever a command queue is updated, which then informs the appropriate object. Which of these do you think would be better? Or is there another way I haven't thought of?

Oh, this is a .NET windows project in C#.
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
I'm very newbie at C#, but here's how I'd do it, or something like this. Basically call the function of the other form. I apologize if the code has syntax errors.
 

Deeko

Lifer
Jun 16, 2000
30,213
12
81
I don't think that would work. Form2 is not a member of Form1, it is a member of the Main program. Thus, you can't access its functions.