• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Best way to link mulitple objects?

Deeko

Lifer
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#.
 
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.
 
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.
 
Back
Top