Thursday, May 17, 2007

Communicating Using Events & Shared State

Communicating Using Events
Components that want to publish or receive notifications can use events. The Composite UI Application Block contains an eventbroker system that enables you to implement a multicast event scheme.

You publish an event by adding the EventPublication attribute to an event declaration, as shown in the following code.

[EventPublication("topic://UpdatesAvailable", PublicationScope.Global)]
public event EventHandler> UpdatesAvailable;
// or
[EventPublication("topic://UpdatesAvailable", PublicationScope.Global)]
public event EventHandler UpdatesAvailable;


Communicating Using Shared State
The WorkItem class can store state. SmartParts in a WorkItem can access this state to communicate with other components in the same WorkItem. The following code shows how to access the state stored within a WorkItem.

myWorkItem.State["CustName"] = textbox1.Text;

No comments: