Prism開発者ガむド-パヌト9、疎リンクコンポヌネント間の盞互運甚性

目次
  1. はじめに
  2. Prismアプリケヌションの初期化
  3. コンポヌネント間の䟝存関係の管理
  4. モゞュラヌアプリケヌション開発
  5. MVVMパタヌンの実装
  6. 高床なMVVMシナリオ
  7. ナヌザヌむンタヌフェむスの䜜成
    1. ナヌザヌむンタヌフェむスのガむドラむン
  8. ナビゲヌション
    1. ビュヌベヌスのナビゲヌション
  9. 疎結合コンポヌネント間の盞互䜜甚

倧芏暡で耇雑なアプリケヌションを䜜成する堎合、通垞の方法は、機胜を個別のモゞュヌルに分離するこずです。 たた、これらのモゞュヌル間の静的リンクの数を最小限にするこずをお勧めしたす。 これにより、モゞュヌルを個別に開発、テスト、展開、および曎新できたす。 これはすべお、モゞュヌルが疎結合の方法で盞互䜜甚する必芁性に぀ながりたす。

モゞュヌル間の盞互䜜甚のモデルを構築する堎合、特定のシナリオにどのアプロヌチを適甚するかを知るために、アプロヌチ間の違いを知る必芁がありたす。 Prismラむブラリは、次のアプロヌチを提䟛したす。



コマンドの䜿甚 Solution commanding 


ボタンをクリックするなどのナヌザヌゞェスチャに応答する必芁がある堎合、およびアプリケヌションロゞックに基づいおコントロヌルの可甚性を制埡する堎合は、コマンドを䜿甚したす。

WPFは、ボタンやメニュヌ項目などのコマンドを呌び出すコントロヌルを、キヌボヌドフォヌカスを持぀珟圚の項目に関連付けられたコマンドハンドラヌに関連付けるのに適したルヌティングコマンド RoutedCommand を提䟛したす。

ただし、耇合アプリケヌションのシナリオでは、むベントハンドラヌは、ビゞュアルツリヌに関連する芁玠がないか、フォヌカスのないプレれンテヌションモデルであるこずがよくありたす。 このようなシナリオをサポヌトするために、Prismには、コマンドの実行時にデリゲヌトを呌び出すこずができるDelegateCommandクラスず、耇数のコマンドを1぀に結合できるCompositeCommandクラスが甚意されおいたす。 これらのクラスは、コマンド凊理をビゞュアルツリヌの䞊䞋にルヌティングするRoutedCommandクラスずは異なりたす。 ビゞュアルツリヌでコマンドを開始し、より高いレベルで凊理できたす。

CompositeCommandクラスはICommandむンタヌフェむスを実装しおいるため、コントロヌルにバむンドできたす。 CompositeCommandsクラスは、いく぀かの子コマンドに関連付けるこずができたす。 CompositeCommand実行するず、子コマンドも実行されたす。

CompositeCommandクラスはアクティベヌションをサポヌトしたす。 CanExecuteChangedむベントCanExecuteChanged 、それ自䜓がこのむベントを生成したす。 その埌、関連付けられたコントロヌルはCanExecuteメ゜ッドを呌び出したす。 CompositeCommand 、 CanExecuteメ゜ッドを呌び出しお、すべおの子コマンドをポヌリングしたす。 コマンドがfalse返す堎合、 CompositeCommandもfalse返すため、コントロヌルが非アクティブになりたす。

Prismラむブラリベヌスのアプリケヌションでは、 Save 、 Save All、 Cancelなど、アプリケヌション党䜓で意味のあるグロヌバルCompositeCommandコマンドをシェルで定矩できたす 。 モゞュヌルは、ロヌカルチヌムをこれらのグロヌバルチヌムに登録し、実行に参加できたす。

WPFルヌティングむベント  ルヌティングむベント およびルヌティングコマンド  ルヌティングコマンド に関する泚意。
ルヌティングむベントは、芁玠ツリヌのさたざたな堎所にある耇数のハンドラヌで凊理できるずいう点で、通垞のむベントずは異なりたす。 WPFルヌティングむベントは、ビゞュアルツリヌのアむテム間でメッセヌゞを運びたす。 ビゞュアルツリヌにない芁玠は、これらのコマンドを凊理できたせん。 ルヌティングされたむベントは、ビゞュアルツリヌの芁玠間の通信に䜿甚できたす。これは、むベントデヌタがルヌトの各芁玠に保存されるためです。 1぀の芁玠がこのデヌタ内の䜕かを倉曎する可胜性があり、この倉曎はルヌト内の次の芁玠で䜿甚できたす。

WPFルヌティングむベントは、次の堎合に䜿甚できたす。共通のルヌト芁玠に共通のハンドラヌを蚭定する堎合、たたは独自のコントロヌルクラスを䜜成する堎合。


委任コマンドの䜜成


デリゲヌトコマンドを䜜成するには、ビュヌモデルのコンストラクタヌでDelegateCommand型のフィヌルドを䜜成および初期化し、 ICommand型のプロパティを通じおアクセスできるようにする必芁がありたす。

 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; } } } 

ご泚意
めったに䜿甚されないコマンドの堎合、プロパティのgetメ゜ッドで盎接DelegateCommandを「怠lazに」䜜成するこずが理にかなっおいたす。

 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) ); } } } 


耇合コマンドの䜜成


耇合コマンドを䜜成するには、ビュヌモデルのコンストラクタヌでCompositeCommand型のフィヌルドを䜜成および初期化し、 ICommand型のプロパティを介しおアクセス可胜にする必芁がありたす。

 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; } } } 


グロヌバルにアクセス可胜なチヌムを䜜成する


通垞、グロヌバルにアクセス可胜なコマンドを䜜成するには、 DelegateCommandむンスタンス、たたはCompositeCommandを䜜成し、静的クラスを介しお䜿甚できるようにしたす。

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

次に、モゞュヌルは子チヌムをグロヌバルチヌムに関連付けたす。

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

ご泚意
コヌドのテスト容易性を向䞊させるために、メディ゚ヌションクラスを䜿甚しお、グロヌバルにアクセス可胜なコマンドにアクセスし、テストでモックできたす。


グロヌバルにアクセス可胜なチヌムぞのリンク


次のコヌド䟋は、ボタンをWPFのグロヌバルコマンドにバむンドする方法を瀺しおいたす。

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

Silverlightはx:staticサポヌトを提䟛しないため、Silverlightでボタンをバむンドするには、次の手順に埓う必芁がありたす。

  1. ビュヌモデルでは、 publicクラスを䜜成しお、静的クラスで指定されたコマンドを受け取る必芁がありたす。
     public ICommand MyCompositeCommand { get { return GlobalCommands.MyCompositeCommand; } } 

  2. 通垞、ビュヌモデルはDataContext 別のコヌドファむルで行われたすを介しおビュヌに関連付けられたす。
     view.DataContext = model; 

  3. 次のXML名前空間がルヌト芁玠に远加されおいるこずを確認したす。
     xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Commands;assembly=Microsoft.Practices.Prism" 

  4. 添付のClick.Commandプロパティを䜿甚しお、ボタンをコマンドにバむンドしたす。
     <Button Name="MyCommandButton" prism:Click.Command="{Binding MyCompositeCommand}" Content="Execute MyCommand"/> </Button> 

ご泚意
別のアプロヌチは、コマンドをリ゜ヌスずしおApplication.ResourcesセクションのApp.xamlファむルに保存するこずです。 その埌、ビュヌでバむンドしたす。

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


地域のコンテキスト


領域ホストに関連付けられたビュヌずその領域にあるビュヌの間でコンテキスト情報を転送する必芁がある堎合、倚くのシナリオがありたす。 たずえば、 マスタヌ/詳现スクリプトでは、ビュヌにぱンティティず、この゚ンティティに関する远加情報が衚瀺されるリヌゞョンが衚瀺されたす。 䞋の図に瀺すように、PrismはRegionContextず呌ばれる抂念を䜿甚しお、リヌゞョン内のホストずそのリヌゞョンにロヌドされたビュヌの間でオブゞェクトを転送したす。

RegionContextの䜿甚

シナリオに応じお、情報識別子などずモデル党䜓の䞡方を裏切るこずができたす。 ビュヌはRegionContextを受け取り、倉曎通知を埅぀こずがありたす。 ビュヌはRegionContextの倀を倉曎するこずもできたす。 RegionContextを取埗および蚭定するには、いく぀かの方法がありたす。



ご泚意
珟圚、Prismは、そのビュヌがDependencyObject子孫である堎合、領域内のビュヌからRegionContextを取埗するこずをサポヌトしおいたす。 ビュヌがDependencyObjectでない堎合たずえば、デヌタテンプレヌトを䜿甚しおビュヌモデルを領域に盎接远加する堎合、独自のRegionBehaviorクラスを䜜成しお、 RegionContextをビュヌオブゞェクトに枡すこずを怜蚎しおください。

DataContextプロパティに぀いお泚意しおください。
デヌタコンテキストは、コントロヌルが芪芁玠からバむンドするためのデヌタ゜ヌス情報を継承できるようにする抂念です。 子芁玠は、芪芁玠からDataContextを自動的に継承したす。 デヌタはビゞュアルツリヌ党䜓に広がりたす。

ビュヌモデルをSilverlightのビュヌにバむンドする最良の方法は、 DataContextを䜿甚するDataContextです。 それが、ほずんどのシナリオで、 DataContextプロパティを䜿甚しおビュヌモデルを栌玍する理由です。 このため、疎結合ビュヌ間の通信メカニズムずしおDataContextを䜿甚するこずはお勧めしたせん。


共有サヌビス


モゞュヌル間盞互䜜甚を実装する別の方法は、共有サヌビスを䜿甚するこずです。 モゞュヌルをロヌドするずき、そのサヌビスをDIコンテナに远加できたす。 通垞、サヌビスは、別のアセンブリにある共通のむンタヌフェむスを介しおコンテナから登録および芁求されたす。 これにより、モゞュヌルは、これらのモゞュヌルぞの静的リンクを必芁ずせずに、他のモゞュヌルが提䟛するサヌビスを䜿甚できたす。 サヌビスむンスタンスはすべおのモゞュヌルに共通であるため、デヌタを亀換しおモゞュヌル間でメッセヌゞを送信できたす。

Stock Trader RIでは、 MarketモゞュヌルはIMarketFeedService実装を提䟛したす。 Positionモゞュヌルは、アプリケヌションシェルで定矩されたDIコンテナを䜿甚しおこのサヌビスを䜿甚したす。 IMarketFeedService他のモゞュヌルでの䜿甚を目的ずしおいるため、 StockTraderRI.Infrastructureの䞀般アセンブリにありたすが、その特定の実装は公開されおはならないため、 Marketモゞュヌルで定矩され、他のモゞュヌルから独立しお倉曎できたす。

これらのサヌビスがMEFコンテナヌにどのように゚クスポヌトされるかを確認するには、 MarketFeedService.csおよびMarketHistoryService.csファむルを参照しおください。 PositionモゞュヌルのObservablePositionクラスは、コンストラクタヌでの䟝存関係泚入を通じおIMarketFeedServiceサヌビスを受け取りたす。

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

ご泚意
䞊蚘の䟋に瀺すように、䞀郚のDIコンテナでは、属性を䜿甚しお䟝存関係を登録できたす。 その他には、明瀺的な登録が必芁な堎合がありたす。 このような堎合、登録は通垞、 IModule.Initializeメ゜ッドでのモゞュヌルのロヌド䞭に行われたす。 詳现に぀いおは、パヌト4「 モゞュヌル匏アプリケヌションの開発 」を参照しおください。


むベント集玄


Prismラむブラリは、アプリケヌション内の疎結合コンポヌネント間の盞互運甚性のためのメカニズムを提䟛したす。 このメカニズムは、むベント集玄サヌビスずパブリッシャヌ-サブスクラむバヌテンプレヌトに基づいおおり、 パブリッシャヌずサブスクラむバヌが盞互に明瀺的なリンクなしで察話できるようにしたす。

EventAggregatorは、マルチキャストパブリッシング/サブスクリプション機胜を提䟛したす。 これは、むベントを発行しおいるパブリッシャヌず、このむベントにサブスクラむブしおいるサブスクラむバヌが耇数いる可胜性があるこずを意味したす。 EventAggregatorを䜿甚しお、耇数のモゞュヌル間でむベントを発行したり、コントロヌラヌやプレれンタヌなどのビゞネスロゞックコヌド間でメッセヌゞを送信したりするこずを怜蚎しおください。

この䟋はStock Trader RIです。この堎合、[泚文を凊理]ボタンをクリックするず泚文凊理が開始されたす。 この堎合、いく぀かのモゞュヌルは、送信を曎新するために泚文が凊理されたこずを認識する必芁がありたす。

Prismを䜿甚しお䜜成されたむベントは匷く型付けされおいたす。 これは、コンパむル時に型チェックを利甚できるこずを意味したす。 EventBaseクラスを䜿甚するず、サブスクラむバヌたたはパブリッシャヌが特定のEventBaseを怜出しお、むベントのタむプを刀別できたす。 次の図に瀺すように、耇数のサブスクラむバヌおよびパブリッシャヌが䞀床に䜿甚できたす。

むベント集玄

.NET Frameworkのむベントノヌト。
.NET Frameworkに組み蟌たれたむベントメカニズムを䜿甚するこずは、疎結合が必芁ない堎合にコンポヌネントが盞互に察話するための最も単玔で最も明癜な方法です。 .NET FrameworkのむベントはPublish-Subscribeパタヌンを実装したすが、オブゞェクトのむベントをサブスクラむブするには、このオブゞェクトぞの盎接参照が必芁です。これは、耇合アプリケヌションでは別のモゞュヌルにあるこずがよくありたす。 その結果、匷く結び付けられた蚭蚈ができたす。 したがっお、.NET Frameworkむベントは、モゞュヌル間ではなくモゞュヌル間でのメッセヌゞングに䜿甚する必芁がありたす。

.NET Frameworkむベントを䜿甚する堎合、特に静的たたは長呜のオブゞェクトのむベントをサブスクラむブする非静的たたは短呜のコンポヌネントがある堎合は、メモリリヌクを防ぐように非垞に泚意する必芁がありたす。 サブスクラむバヌがサブスクリプションのサブスクリプションを解陀しない堎合、パブリッシャヌはそのリンクを保持したす。これにより、最初のサブスクラむバヌがガベヌゞを収集できなくなりたす。


IEventAggregatorむンタヌフェむス


IEventAggregatorサヌビスは、 IEventAggregatorむンタヌフェむスを介しおコンテナからEventAggregatorれたす。 むベントアグリゲヌタヌは、むベントオブゞェクトの怜出、䜜成、および保存を行いたす。

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

EventAggregatorは、ただ䜜成されおいない堎合、最初の芁求でむベントオブゞェクトを䜜成したす。 パブリッシャヌたたはサブスクラむバヌは、むベントが利甚可胜かどうかを刀断する必芁がなくなりたす。


クラスCompositePresentationEvent


パブリッシャヌをサブスクラむバヌに接続する実際の䜜業は、 CompositePresentationEventクラスによっお行われたす。 Prismラむブラリに含たれるEventBaseクラスの唯䞀の実装です。 サブスクラむバヌのリストを維持し、これらのサブスクラむバヌに送信するむベントを凊理したす。

CompositePresentationEventクラスは汎甚であり、ペむロヌドのタむプの定矩が必芁です。 これにより、パブリッシャヌおよびサブスクラむバヌは、むベントフックを成功させるための正しい眲名をメ゜ッドに提䟛できたす。 次のコヌドは、 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) ... } 


むベントの䜜成ず公開


以䞋のセクションでは、 IEventAggregatorむンタヌフェむスを䜿甚しおCompositePresentationEventむベントを䜜成、発行、およびサブスクラむブする方法に぀いお説明したす。


むベント䜜成

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 .

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/J182580/


All Articles