Hi everyone I need a advice, I\'m developing a desktop application (Winform) using C#, I have a Form and I have a separated class named OPC (other file)
This is s
If you are asking whether to use events or whether to just directly call into something, it depends on your use case. Events are a great way to broadcast an action. If more than one item needs to know about something changing using events can decouple your code. That said, if you only care about telling one other piece of code then you can do that too. Events are dispatched on the same thread, so whether you directly call into the subscriber or dispatch it with an event, the executing code is handled in the same context.
Personally I like to use events to prevent hard coupling. Your dispatcher code doesn't need to know who is subscribing on it. It just says "hey, stuff happened, now you do work".
Events are also neat because you can combine them with Rx to get sampling and throttling and do all sorts of other cool stuff.
If you find you are adding a bunch of extra code to propagate that "something happened", you should use an event.