本文整理汇总了C#中Subject.ObserveOnDispatcher方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.ObserveOnDispatcher方法的具体用法?C# Subject.ObserveOnDispatcher怎么用?C# Subject.ObserveOnDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.ObserveOnDispatcher方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObserveWindowViewModel
public ObserveWindowViewModel( string filename, IActorRef tailCoordinator )
{
_tailCoordinator = tailCoordinator;
Filename = filename;
Title = filename;
Items = new ReactiveList<String>();
// start coordinator
_tailCoordinator.Tell( new TailCoordinatorActor.StartTail( filename, this ) );
// this is how we can update the viewmodel
// from the actor.
Lines = new Subject<String>();
Lines.ObserveOnDispatcher().Subscribe( item =>
{
Items.Add( item );
if ( Items.Count > 1500 )
{
Items.RemoveAt( 0 );
}
SelectedLine = Items.Count - 1;
} );
}
示例2: StatsWindowViewModel
/// <summary>
/// Initializes a new instance of the <see cref="StatsWindowViewModel"/> class.
/// </summary>
public StatsWindowViewModel()
{
Items = new ReactiveList<StatViewModel>();
// this is how we can update the viewmodel
// from the actor.
AddItem = new Subject<PublishMetrics>();
AddItem.ObserveOnDispatcher().Subscribe(item => HandleNewItemOnList(item));
m_vmActor = AkkaSystem.System.ActorOf(StatObserver.GetProps(this), "stat-window");
Publisher = AkkaSystem.System.ActorSelection("/user/" + AkkaSystemMonitorActor.Name);
// TODO: what to do if publisher not found.
Publisher.Tell(new SubscribeMonitorMessage(m_vmActor));
}
示例3: MainWindowViewModel
public MainWindowViewModel()
{
Extension = "*.docx";
Folders = @"C:\Test\Test Docs";
Items = new ReactiveList<ResultItem>();
CountCommand = ReactiveCommand.Create();
CountCommand.Subscribe(x => DoCount());
// this is how we can update the viewmodel
// from the actor.
AddItem = new Subject<ResultItem>();
AddItem.ObserveOnDispatcher().Subscribe(item => Items.Add(item));
m_vmActor = AkkaSystem.System.ActorOf(DocumentInspectorSupervisor.GetProps(this), ActorPaths.DocumentInspectorSupervisor.Name);
}
示例4: MainWindowViewModel
public MainWindowViewModel()
{
Extension = "*.txt";
// Folders = @"c:\Users\njimenez\Documents\Projects\CSharp\Games\Poker";
Folders = @"d:\downloads";
Items = new ReactiveList<ResultItem>();
CountCommand = ReactiveCommand.Create();
CountCommand.Subscribe( x => DoCount() );
// this is how we can update the viewmodel
// from the actor.
AddItem = new Subject<ResultItem>();
AddItem.ObserveOnDispatcher().Subscribe( item => Items.Add( item ) );
m_vmActor = AkkaSystem.System.ActorOf( WordCounterSupervisor.GetProps( this ), ActorPaths.WordCounterSupervisorActor.Name );
}
示例5: MainWindowViewModel
public MainWindowViewModel()
{
Extension = "*.txt";
Folders = @"c:\";
Items = new ReactiveList<FileInfoViewModel>();
CrawlCommand = ReactiveCommand.Create();
CrawlCommand.Subscribe( x => Handle() );
ObserveCommand = ReactiveCommand.Create();
ObserveCommand.Subscribe( x => ObserveFile() );
AddItem = new Subject<FileInfoViewModel>();
AddItem.ObserveOnDispatcher().Subscribe( item => Items.Add( item ) );
m_vmActor = App.WinTailSystem.ActorOf( WinTailSupervisor.GetProps( this ), "supervisor" );
m_tailCoordinator = App.WinTailSystem.ActorOf( TailCoordinatorActor.GetProps(), "tailcoordinator" );
}
示例6: LauncherFormViewModel
public LauncherFormViewModel()
{
/* INITIALIZE ACTORS */
var props = Props.Create( () => new MainFormActor( this ) );
m_mainFormActor = App.GithubSystem.ActorOf( props, ActorPaths.MainFormActor.Name );
props = Props.Create( () => new GithubCommanderActor() );
App.GithubSystem.ActorOf( props, ActorPaths.GithubCommanderActor.Name );
props = Props.Create( () => new GithubValidatorActor( GithubClientFactory.GetClient() ) );
App.GithubSystem.ActorOf( props, ActorPaths.GithubValidatorActor.Name );
LaunchSearch = ReactiveCommand.Create( null );
LaunchSearch.Subscribe( x => DoLaunchSearch() );
// to be able to launch a window from the actor system
m_LaunchWindow = new Subject<MainFormActor.LaunchRepoResultsWindow>();
m_LaunchWindow.ObserveOnDispatcher().Subscribe( x => DoLaunchWindow( x ) );
}
示例7: DispatcherMessageQueueThread
public DispatcherMessageQueueThread(string name, Action<Exception> handler)
: base(name)
{
_actionSubject = new Subject<Action>();
_actionObserver = _actionSubject;
_subscription = _actionSubject
#if WINDOWS_UWP
.ObserveOnDispatcher()
#else
.ObserveOn(Dispatcher.CurrentDispatcher)
#endif
.Subscribe(action =>
{
try
{
action();
}
catch (Exception ex)
{
handler(ex);
}
});
}