开发者

CAB/SCSF Command vs Events

开发者 https://www.devze.com 2023-01-28 19:42 出处:网络
What is the difference between the Commands and the Events in CAB? There seem to do the same thing, when is the command intent to be used and the events?开发者_开发技巧From a CAB point of view command

What is the difference between the Commands and the Events in CAB? There seem to do the same thing, when is the command intent to be used and the events?开发者_开发技巧


From a CAB point of view commands were meant to be used specifically for UI components, while events could in theory be used by any component. So commands are a more specific implementation of the event mechanism for UI menus, actions, etc...

Below are links to an excellent article series by Rich Newman on CAB. Chapter 10 and 11 are on commmands and events in CAB.

http://richnewman.wordpress.com/intro-to-cab-toc/

http://richnewman.wordpress.com/2007/09/22/introduction-to-events-in-the-cab-introduction-to-cabscsf-part-11/

http://richnewman.wordpress.com/2007/09/16/commands-in-the-cab-introduction-to-cabscsf-part-10/


Leaving CAB aside, by theory;

  • Command: represents an action, that can be reused or not through different parts of the application. means "Do this".
  • Event: represents that something happened, so every instance attached to that event might decide to do different things when the event is published. means "this happened"

So I guess that, if for a given action you want to do always the same thing, then use a command. If not use an event.

I'm currently using Prism (adapted to work with Windows forms) and so far I've not used events for communication.

0

精彩评论

暂无评论...
验证码 换一张
取 消