本文整理汇总了C#中ISubject.OnNext方法的典型用法代码示例。如果您正苦于以下问题:C# ISubject.OnNext方法的具体用法?C# ISubject.OnNext怎么用?C# ISubject.OnNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISubject
的用法示例。
在下文中一共展示了ISubject.OnNext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YieldObservable
public void YieldObservable()
{
coroutine = YieldObservableBlock().AsCoroutine<object>();
subject = new Subject<object>();
Subscribe();
expectedResults.Add(t1);
expectedResults.Add(t2);
AssertExpectedResults();
subject.OnNext(t3);
// don't want to include results from observables yielded
//expectedResults.Add(t3);
AssertExpectedResults();
subject.OnCompleted();
expectedResults.Add(t4);
AssertExpectedResults();
AssertExpectedErrors();
AssertCompleted();
}
示例2: DefaultServerBroker
public DefaultServerBroker(IStorage storage)
{
_storage = storage;
_offRecieverThreadSubject = new Subject<IMessage>();
_offRecieverThreadInternalSubject = new Subject<IMessage>();
OffRecieverThread = new ServerBrokerObservations(_offRecieverThreadSubject);
// ensure off-request data is observed onto a different thread
_offRecieverThreadInternalSubject.Subscribe(payload => Observable.Start(() => _offRecieverThreadSubject.OnNext(payload), TaskPoolScheduler.Default));
}
示例3: MessageStreamResource
public MessageStreamResource(IServerBroker serverBroker)
{
_serverBroker = serverBroker;
_senderSubject = new Subject<Container>();
// setup heart beat to keep alive client connections
Observable.Interval(new TimeSpan(0, 0, 20), TaskPoolScheduler.Default).Subscribe(x => _senderSubject.OnNext(Container.Ping()));
// TODO: See if we can get Defered working there
// lets subscribe, hope of the thread and then broadcast to all connections
//_serverBroker.OffRecieverThread.ListenAll().Subscribe(message => Observable.Defer(() => Observable.Start(() => ProcessMessage(message), TaskPoolScheduler.Default)));
_serverBroker.OffRecieverThread.ListenAll().Subscribe(message => Observable.Start(() => ProcessMessage(message), TaskPoolScheduler.Default));
}
示例4: Connection
public Connection(string address, string username)
{
_statusStream = new BehaviorSubject<ConnectionInfo>(new ConnectionInfo(ConnectionStatus.Uninitialized, address));
Address = address;
_hubConnection = new HubConnection(address);
_hubConnection.Headers.Add(ServiceConstants.Server.UsernameHeader, username);
CreateStatus().Subscribe(
s => _statusStream.OnNext(new ConnectionInfo(s, address)),
_statusStream.OnError,
_statusStream.OnCompleted);
_hubConnection.Error += exception => Log.Error("There was a connection error with " + address, exception);
BlotterHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.BlotterHub);
ExecutionHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.ExecutionHub);
PricingHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.PricingHub);
ReferenceDataHubProxy = _hubConnection.CreateHubProxy(ServiceConstants.Server.ReferenceDataHub);
}
示例5: Connection
public Connection(string address, string username)
{
_statusStream = new BehaviorSubject<ConnectionInfo>(
new ConnectionInfo(ConnectionStatus.Uninitialized, address));
Address = address;
hubConnection = new HubConnection(address);
//hubConnection.Headers.Add(ServiceConstants.Server.UsernameHeader, username);
CreateStatus().Subscribe(
s => _statusStream.OnNext(new ConnectionInfo(s, address)),
_statusStream.OnError,
_statusStream.OnCompleted);
hubConnection.Error += exception => log.Error("There was a connection error with "
+ address, exception);
TickerHubProxy = hubConnection.CreateHubProxy(ServiceConstants.Server.TickerHub);
}
示例6: DefaultAgentBroker
public DefaultAgentBroker(IMessagePublisher messagePublisher, IMessageConverter messageConverter, IContextData<MessageContext> context)
{
_messagePublisher = messagePublisher;
_messageConverter = messageConverter;
_context = context;
_onSenderThreadSubject = new Subject<AgentBrokerPayload>();
_offSenderThreadSubject = new Subject<AgentBrokerPayload>();
_offSenderThreadInternalSubject = new Subject<AgentBrokerPayload>();
_publisherInternalSubject = new Subject<AgentBrokerPayload>();
OnSenderThread = new AgentBrokerObservations(_onSenderThreadSubject);
OffSenderThread = new AgentBrokerObservations(_offSenderThreadSubject);
// ensure off-request data is observed onto a different thread
_offSenderThreadInternalSubject.Subscribe(payload => Observable.Start(() => _offSenderThreadSubject.OnNext(payload), TaskPoolScheduler.Default));
_publisherInternalSubject.Subscribe(x => Observable.Start(() => PublishMessage(x), TaskPoolScheduler.Default));
}
示例7: YieldObserableError
public void YieldObserableError()
{
coroutine = YieldObservableErrorBlock().AsCoroutine<object>();
subject = new Subject<object>();
Subscribe();
subject.OnNext(t2);
subject.OnError(e1);
expectedResults.Add(t1);
//expectedResults.Add(t2);
expectedErrors.Add(e1);
AssertExpectedResults();
AssertExpectedErrors();
AssertNotCompleted();
}
示例8: StartReportingProgress
protected virtual IDisposable StartReportingProgress(Aria2cClientEventArgs args, Func<Aria2cClientEventArgs, Aria2cClientEventArgs> getProgress, Action<Aria2cClientEventArgs> completed, ISubject<Aria2cClientEventArgs> subject)
{
_logger.Info("Observando progresso de {0}.", args.Status.Gid);
ThreadPoolScheduler scheduler = Scheduler.ThreadPool;
Action<Action> work = self =>
{
try
{
Aria2cClientEventArgs eventArgs = getProgress(args);
if (eventArgs.Status.Completed)
{
completed(eventArgs);
return;
}
subject.OnNext(eventArgs);
}
catch (Aria2cException aex)
{
_logger.DebugException(aex.Message, aex);
subject.OnError(aex);
return;
}
Thread.Sleep(1000);
self();
};
return scheduler.Schedule(work);
}
示例9: MessageBroker
public MessageBroker(IMessagePublisher messagePublisher)
{
_messagePublisher = messagePublisher;
_onRequestThreadSubject = new Subject<Message>();
_offRequestThreadSubject = new Subject<Message>();
_offRequestThreadInternalSubject = new Subject<Message>();
_publisherInternalSubject = new Subject<Message>();
// ensure off-request data is observed onto a different thread
_offRequestThreadInternalSubject.Subscribe(x => Observable.Start(() => _offRequestThreadSubject.OnNext(x), TaskPoolScheduler.Default));
_publisherInternalSubject.Subscribe(x => Observable.Start(() => _messagePublisher.Publish(x), TaskPoolScheduler.Default));
}