📜 ⬆️ ⬇️

Prism Developer Guide - Part 9, the interaction between loosely coupled components

Table of contents
  1. Introduction
  2. Initializing Prism Applications
  3. Manage dependencies between components
  4. Modular Application Development
  5. Implementation of the MVVM pattern
  6. Advanced MVVM scripts
  7. Creating user interface
    1. User Interface Design Recommendations
  8. Navigation
    1. View-Based Navigation (View-Based Navigation)
  9. The interaction between loosely coupled components

When creating a large and complex application, the usual approach is to divide the functionality into separate modules. It is also desirable to minimize the number of static links between these modules. Due to this, modules can be independently developed, tested, deployed and updated. All this leads to the need for modules to interact with each other in a loosely coupled manner.

When building a model of interaction between modules, it is necessary to know the differences between the approaches in order to know which one to use in a specific scenario. Prism library provides the following approaches:



Using Commands ( Solution commanding )


If you need to respond to user gestures, such as pressing a button, and if you want to control the accessibility of the control depending on the application logic, use commands.
')
WPF provides routed commands ( RoutedCommand ) that are well suited to associate a control that invoked a command, such as a button, or a menu item, with a command handler associated with the current element that has keyboard focus.

However, in composite application scenarios, the event handler is often a view model, or not having any associated elements in the visual tree, or that have no focus. To support such scenarios, Prism provides the DelegateCommand class, which allows you to call a delegate when executing a command, and the CompositeCommand class, which allows you to combine several commands into one. These classes are different from the built-in class RoutedCommand , which routes the processing of a command down and up through the visual tree. They allow you to initiate a command in the visual tree, and process it at a higher level.

The CompositeCommand class implements the ICommand interface, so it can be bound to controls. The CompositeCommands class can be associated with several child commands. When CompositeCommand executed, the child commands will also be executed.

The CompositeCommand class supports activation. When a CanExecuteChanged event CanExecuteChanged , it itself generates this event. After that, the associated control calls the CanExecute method on the CompositeCommand . CompositeCommand polls all child commands by calling their CanExecute method. If any command returns false , the CompositeCommand also returns false , thus deactivating the control.

Applications based on the Prism library can have global CompositeCommand commands defined in the shell that make sense throughout the application, such as Save , Save All and Cancel . Modules can register their local teams with these global teams, thus taking part in their execution.

A note about WPF Routed Events (routed events) and Routed Commands (routed commands).
Routed events differ from ordinary events in that they can be handled by several handlers located in different places in the element tree. WPF routed events carry messages between items in the visual tree. Items that are not in the visual tree cannot process these commands. Routed events can be used for communication between elements of the visual tree, since event data is stored for each element in the route. One item can change something in this data, and this change will be available for the next item in the route.

You can use WPF routed events in the following cases: setting a common handler in a common root element, or when creating your own control class.


Creating a Delegate Command


To create a delegate command, you need to create and initialize a field of type DelegateCommand in the constructor of the view model and make it accessible through the property of the ICommand type.

 public class ArticleViewModel : NotificationObject { private readonly ICommand _showArticleListCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { _showArticleListCommand = new DelegateCommand(this.ShowArticleList); } public ICommand ShowArticleListCommand { get { return _showArticleListCommand; } } } 

The note.
For rarely used commands, it often makes sense to "lazily" create a DelegateCommand directly in the get method of a property.

 public class ArticleViewModel : NotificationObject { private readonly ICommand _showArticleListCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { } public ICommand ShowArticleListCommand { get { return _showArticleListCommand ?? ( _showArticleListCommand = new DelegateCommand(this.ShowArticleList) ); } } } 


Creating a composite command ( Composite command )


To create a composite command, you must create and initialize a field of type CompositeCommand in the constructor of the view model and make it accessible via the ICommand property.

 public class MyViewModel : NotificationObject { private readonly CompositeCommand _saveAllCommand; public ArticleViewModel(INewsFeedService newsFeedService, IRegionManager regionManager, IEventAggregator eventAggregator) { _saveAllCommand = new CompositeCommand(); _saveAllCommand.RegisterCommand(new SaveProductsCommand()); _saveAllCommand.RegisterCommand(new SaveOrdersCommand()); } public ICommand SaveAllCommand { get { return _saveAllCommand; } } } 


Creating globally accessible commands


Usually, to create a globally accessible command, an instance of DelegateCommand , or CompositeCommand , is created and made available through a static class.

 public static class GlobalCommands { public static CompositeCommand MyCompositeCommand = new CompositeCommand(); } 

Then, in the module, the child commands are associated with the global team.

 GlobalCommands.MyCompositeCommand.RegisterCommand(command1); GlobalCommands.MyCompositeCommand.RegisterCommand(command2); 

The note.
To improve code testability, you can use a proxy class to access a globally accessible command and mock it in tests.


Binding to globally accessible commands


The following code example shows how to bind a button to a global team in WPF.

 <Button Name="MyCompositeCommandButton" Command="{x:Static local:GlobalCommands.MyCompositeCommand}" Content="Execute My Composite Command"> </Button> 

Silverlight does not provide support for x:static , so to bind a button in Silverlight, you need to follow these steps:

  1. In the view model, you need to create a public property to get the command specified in the static class.
     public ICommand MyCompositeCommand { get { return GlobalCommands.MyCompositeCommand; } } 

  2. Typically, view models are associated with views through a DataContext (which is done in a separate code file).
     view.DataContext = model; 

  3. Ensure that the following XML namespace is added to the root element.
     xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism" 

  4. Assign a button to a command using the attached Click.Command property.
     <Button Name="MyCommandButton" prism:Click.Command="{Binding MyCompositeCommand}" Content="Execute MyCommand"/> </Button> 

The note.
Another approach is to save the command as a resource in the App.xaml file in the Application.Resources section. After that, in the submission, make a binding to it.

 <Button Name="MyCommandButton" prism:Click.Command="{Binding MyCompositeCommand, Source={StaticResource GlobalCommands}} Content="Execute MyCommand"/> </Button> 


Region context


There are many scenarios where it may be necessary to transfer contextual information between a view associated with a region (host) and views that are in that region. For example, in the master-detail script, the representation displays the entity and the region in which additional information is displayed for this entity. Prism uses a concept called RegionContext to transfer an object between a region's host and views loaded into that region, as shown in the illustration below.

Using RegionContext

Depending on the scenario, you can betray both a piece of information (such as an identifier) ​​and the entire model. A view can receive a RegionContext and then wait for a change notification. The view can also change the RegionContext value. There are several ways to get and set up with RegionContext :



The note.
Currently, Prism supports getting RegionContext from a view within a region, if that view is a descendant of a DependencyObject . If your view is not DependencyObject (for example, if you use data templates and add a view model directly to a region), consider creating your own RegionBehavior class to pass the RegionContext to the view objects.

A note about the DataContext property.
The data context is a concept that allows controls to inherit data source information for binding from their parent elements. Child elements automatically inherit the DataContext from their parent elements. Data spreads down the visual tree.

The best way to bind a view model to a view in Silverlight is to use the DataContext . That is why, in most scenarios, the DataContext property is used to store the view model. Because of this, it is not recommended to use DataContext as a communication mechanism between loosely coupled views.


Shared services


Another way to implement inter-module communication is to use common services. When loading a module, it can add its services to the DI container. Usually, services are registered and requested from the container on common interfaces, which are located in a separate assembly. This allows modules to use services provided by other modules, without the need to create static links to these modules. Instances of services are common to all modules, so you can exchange data and send messages between them.

In Stock Trader RI , the Market module provides an implementation of IMarketFeedService . The Position module consumes this service using the DI container defined in the application shell. IMarketFeedService intended for use by other modules, so it is located in the general assembly of StockTraderRI.Infrastructure , but its specific implementation should not be publicly available, so it is defined in the Market module and can change independently of other modules.

To see how these services are exported to the MEF container, see the MarketFeedService.cs and MarketHistoryService.cs files . The Position module's ObservablePosition class gets the IMarketFeedService service through dependency injection into the constructor.

 [Export(typeof(IMarketFeedService))] [PartCreationPolicy(CreationPolicy.Shared)] public class MarketFeedService : IMarketFeedService, IDisposable { ... } 

The note.
Some DI containers allow you to register dependencies using attributes, as shown in the example above. Others may require explicit registration. In such cases, registration is usually done at module load time in the IModule.Initialize method. For more information, see Part 4, Developing Modular Applications .


Event Aggregation


The Prism library provides a mechanism to allow interaction between loosely coupled components in an application. This mechanism is based on the event aggregation service and the Publisher-Subscriber pattern, which allows publisher (s) and subscriber to interact without explicit references to each other.

EventAggregator provides multi-address publishing / subscription functionality. This means that there may be several publishers publishing an event, and several subscribers who subscribe to this event. Consider using EventAggregator to publish events between multiple modules and when sending messages between business logic code, such as controllers and presenters.

An example of this is the Stock Trader RI , in which when you click the Process Order button, order processing starts. In this case, several modules need to know that the order is processed in order to update their views.

Events created with Prism are strongly typed. This means that you can take advantage of type checking at compile time. The EventAggregator class allows subscribers, or publishers, to detect a specific heir to EventBase to determine the type of event. It can be used by several subscribers and publishers at once, as shown in the illustration below.

Event aggregation

A note on events in the .NET Framework.
Using the event mechanism built into the .NET Framework is the simplest and most obvious way for components to communicate with each other, if weak connectivity is not required. Events in the .NET Framework implement the Publish-Subscribe template, but to subscribe to an object event, an immediate reference to this object is required, which, in composite applications, is often located in another module. The result is a strongly related design. Consequently, the .NET Framework events should be used to exchange messages within modules, but not between them.

If you are using the .NET Framework events, you must be very careful not to allow memory leaks, especially if you have non-static or short-lived components that subscribe to events of a static or long-lived object. If the subscriber does not unsubscribe, the link to it will be saved by the publisher, which will prevent the garbage collector from releasing the first one.


IEventAggregator interface


Getting the EventAggregator service from the container happens through the IEventAggregator interface. The event aggregator is responsible for detecting, or creating and saving event objects.

 public interface IEventAggregator { TEventType GetEvent<TEventType>() where TEventType : EventBase; } 

EventAggregator creates an event object on the first request, if it has not yet been created. It frees the publisher or subscriber from having to determine if an event is available.


CompositePresentationEvent class


The real work of connecting publishers with subscribers is done by the CompositePresentationEvent class. It is the only implementation of the EventBase class included in the Prism library. It maintains a list of subscribers and handles sending events to these subscribers.

The CompositePresentationEvent class is generic and requires the definition of the type of payload. This helps publishers and subscribers provide methods with the correct signature for successfully connecting events. The following code shows a partial definition of the class CompositePresentationEvent .

 public class CompositePresentationEvent<TPayload> : EventBase { ... public SubscriptionToken Subscribe(Action<TPayload> action); public SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption); public SubscriptionToken Subscribe(Action<TPayload> action, bool keepSubscriberReferenceAlive) public virtual SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive); public virtual SubscriptionToken Subscribe(Action<TPayload> action, ThreadOption threadOption, bool keepSubscriberReferenceAlive, Predicate<TPayload> filter); public virtual void Publish(TPayload payload); public virtual void Unsubscribe(Action<TPayload> subscriber); public virtual bool Contains(Action<TPayload> subscriber) ... } 


Create and publish events


The following sections describe how to create, publish, and subscribe to CompositePresentationEvent events using the IEventAggregator interface.


Event creation

The CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
class is CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .

CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .

CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
 CompositePresentationEvent      ,   ,  . TPayLoad     .    ,       . 

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .
CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .

CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .

CompositePresentationEvent , , . TPayLoad . , .

, TickerSymbolSelectedEvent Stock Trader RI . , . , .

public class TickerSymbolSelectedEvent : CompositePresentationEvent<string> { }
.
, , . Stock Trader RI , StockTraderRI.Infrastructure .



EventAggregator Publish . EventAggregator , , IEventAggregator .

, TickerSymbolSelectedEvent .

this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Publish("STOCK0");


, Subscribe CompositePresentationEvent . CompositePresentationEvents . .

, UI. , . , . , .

.


UI
, UI . WPF Silverlight, UI UI.

, . UI, UI. , UI. , UI, Dispatcher .

CompositePresentationEvent , UI. , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews, ThreadOption.UIThread); } public void ShowNews(string companySymbol) { this.articlePresentationModel.SetTickerSymbol(companySymbol); }
ThreadOption :

PublisherThread . . . BackgroundThread . .NET Framework. UIThread . UI.


. , filter . System.Predicate , , , .

, -, .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId);

.
- Silverlight, , ( CompositePresentationEvent ). - , Silverlight. , public , keepSubscriberReferenceAlive true , ( ).

- Silverlight, public , , , ( ).

public bool FundOrderFilter(FundOrder fundOrder){ return fundOrder.CustomerId == this.customerId; } ... FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, FundOrderFilter);
.
Subscribe Microsoft.Practices.Prism.Events.SubscriptionToken , . , -, , .

.
, . .


( Strong references )
, , , , , . .

, CompositePresentationEvent . , , CompositePresentationEvent , . .

, keepSubscriberReferenceAlive Subscribe , .

FundAddedEvent fundAddedEvent = eventAggregator.GetEvent<FundAddedEvent>(); bool keepSubscriberReferenceAlive = true; fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, keepSubscriberReferenceAlive, fundOrder => fundOrder.CustomerId == _customerId);
keepSubscriberReferenceAlive bool :

true , , . , . false ( , ), , . , .


, , , . , TickerSymbolSelectedEvent , string , .

public void Run() { ... this.eventAggregator .GetEvent<TickerSymbolSelectedEvent>() .Subscribe(ShowNews); } public void ShowNews(string companySymbol) { articlePresentationModel.SetTickerSymbol(companySymbol); }


, , , .

, , .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.PublisherThread); fundAddedEvent.Unsubscribe(FundAddedEventHandler);
, , . Subscribe .

FundAddedEvent fundAddedEvent = this.eventAggregator.GetEvent<FundAddedEvent>(); subscriptionToken = fundAddedEvent.Subscribe( FundAddedEventHandler, ThreadOption.UIThread, false, fundOrder => fundOrder.CustomerId == this.customerId); fundAddedEvent.Unsubscribe(subscriptionToken);


, "Weak References" MSDN: http://msdn.microsoft.com/en-us/library/ms404247.aspx .

Source: https://habr.com/ru/post/182580/


All Articles