Example #1
0
 public Task Start(CancellationTokenSource token)
 {
     return(Task.Factory.StartNew(() =>
     {
         Ask askToUpDate;
         AskLeg askLegToUpdate;
         while (!token.IsCancellationRequested || AsksToUpdate.Count > 0)
         {
             while (AsksToUpdate.TryDequeue(out askToUpDate))
             {
                 UpdateAsk(askToUpDate);
             }
             while (AskLegsToUpdate.TryDequeue(out askLegToUpdate))
             {
                 UpadateAskLeg(askLegToUpdate);
             }
             Thread.Sleep(10000);
         }
     }, token.Token));
 }
Example #2
0
        public void ExecuteAsk(Ask ask, IEnumerable <Order> orders, IEnumerable <Ask> orderLegAsks, IEnumerable <AskLeg> askLegs)
        {
            using (var context = new InfoExchangeContext())
            {
                using (var scope = new TransactionScope())
                {
                    AsksToUpdate.Enqueue(ask);
                    foreach (var order in orders)
                    {
                        SaveOrder(order, context);
                        if (orderLegAsks != null)
                        {
                            foreach (var orderAsk in orderLegAsks)
                            {
                                AsksToUpdate.Enqueue(orderAsk);
                            }
                        }
                    }

                    scope.Complete();
                }
            }
        }