C# Callback problems


i have a prioblem with a callback because my Form1 open Form2 and send data to Form2 after this return information to another form…please help

i can send object from form1 to form2, but the result of the form2 method must be returned by callback to another form(example form 3).

i hope that you understood my question..

Best Solution

The fact that you have multiple forms operating on the same data means that a better option is to encapsulate that data in a set of "model" classes that can handle both handing out information to your forms and persisting any changes to storage as necessary.

The advantage of this is when you have multiple forms that need to deal with the same data, you can publish callbacks on the model objects for change notification. Each form subscribes to the events in the model that it cares about and it means any number of forms can manipulate your model and all the forms can maintain current state by reacting to notifications.

When does this way you don't care about which forms are manipulating the data and you don't need to pass anything more than the model class when launching a new form. Likewise, when a form requests a save, all the forms can update the state so they don't show the pending change.