コード例 #1
0
        private async Task SubscribeBlock(InQueueBlock <TCriteria, TActionArg> block)
        {
            try
            {
                var disposable = await provider.Subscribe(block.Criteria, candle =>
                {
                    if (block.CanReceiveUpdates)
                    {
                        block.OnNextAction(candle);
                    }
                }, error => { ReportBlockError(block, error); })
                                 .ConfigureAwait(false);

                block.TryMarkAsAlive(disposable);
            }
            catch (Exception e)
            {
                if (block.CanReceiveErrors)
                {
                    ReportBlockError(block, e);
                }
                else
                {
                    NotifyException(e);
                }
            }
        }
コード例 #2
0
 private static void ReportBlockError(InQueueBlock <TCriteria, TActionArg> block, Exception error)
 {
     if (block.CanReceiveErrors)
     {
         block.ErrorAction(error);
     }
 }
コード例 #3
0
        public Task <IDisposable> Subscribe(TCriteria criteria,
                                            Action <TActionArg> onNextAction, Action <Exception> errorAction)
        {
            var block = new InQueueBlock <TCriteria, TActionArg>(criteria, onNextAction, errorAction);

            var disposable = new FridayDisposable(() => { block.MarkBlockAsNonUsable(); });

            lock (actualBlocks)
                actualBlocks.Add(block);

            return(Task.FromResult <IDisposable>(disposable));
        }