static void Main(string[] args) { ServiceHost hostTimerService = new ServiceHost(typeof(TimerService), new Uri("http://localhost:8080/TimerService")); ServiceHost hostTimerClient = new ServiceHost(typeof(TimerClient), new Uri("http://localhost:8080/TimerClient")); ChannelFactory <ITimerService> proxyFactory = null; try { // start the services hostTimerService.Open(); hostTimerClient.Open(); // subscribe to ITimerService proxyFactory = new ChannelFactory <ITimerService>(new BasicHttpBinding(), "http://localhost:8080/TimerService"); ITimerService timerService = proxyFactory.CreateChannel(); timerService.Subscribe("http://localhost:8080/TimerClient"); ((ICommunicationObject)timerService).Close(); // wait for call backs... Console.WriteLine("Wait for Elapsed updates. Press enter to exit."); Console.ReadLine(); } finally { hostTimerService.Close(); hostTimerClient.Close(); proxyFactory.Close(); } }
public GameBase(IOptions gameOptions, ICountrySelector selector, IOptions selectorOptions, ITimerService timerService) { _timerService = timerService; _timerService.Subscribe(RaiseHitScoreChanged); GameOptions = gameOptions; _selector = selector; _selectorOptions = selectorOptions; }
public async Task <string> StartPortfoliosReportUpdate([Service] ITopicEventSender eventSender, [Service] ITimerService timerService, [CurrentUserIdGlobalState] int userId, [Service] ILogger <UpdateMutations> logger) { await eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdatePortfoliosReport), userId); await eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdatePricesReport), userId); var handlerId = timerService.Subscribe((source, args) => { logger.LogInformation("Update portfolios report event"); eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdatePortfoliosReport), userId); eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdatePricesReport), userId); }); return(handlerId); }
public async Task <string> StartAssetReportsUpdate([Service] ITopicEventSender eventSender, [Service] ITimerService timerService, [CurrentUserIdGlobalState] int userId, [Service] ILogger <UpdateMutations> logger) { await eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdateStockReports), userId); await eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdateFondReports), userId); await eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdateBondReports), userId); var handlerId = timerService.Subscribe((source, args) => { logger.LogInformation("Update asset reports event"); eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdateStockReports), userId); eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdateFondReports), userId); eventSender.SendAsync(nameof(ReportSubscriptions.OnUpdateBondReports), userId); }); return(handlerId); }
public ActiveBatchingBuffer(ITimerService timerService, int batchSize, TimerInterval flushInterval = TimerInterval.T_500_Ms) { _timerService = timerService; _batchSize = batchSize; _timerService?.Subscribe(flushInterval, OnFlushTimerElapsed); }