15 using System.Collections.Concurrent;
25 private readonly ConcurrentDictionary<int, CancelPendingOrder> _cancelPendingOrders =
new ConcurrentDictionary<int, CancelPendingOrder>();
39 _cancelPendingOrders[orderId] =
new CancelPendingOrder { Status = status };
49 CancelPendingOrder cancelPendingOrder;
50 if (_cancelPendingOrders.TryGetValue(orderId, out cancelPendingOrder))
55 lock (cancelPendingOrder)
57 if (newStatus.IsClosed())
59 RemoveOrderFromCollection(orderId);
64 if (_cancelPendingOrders.ContainsKey(orderId))
66 _cancelPendingOrders[orderId].Status = newStatus;
79 CancelPendingOrder cancelPendingOrder;
80 if (_cancelPendingOrders.TryGetValue(order.
Id, out cancelPendingOrder))
85 lock (cancelPendingOrder)
87 if (_cancelPendingOrders.ContainsKey(order.
Id))
90 order.
Status = _cancelPendingOrders[order.
Id].Status;
91 RemoveOrderFromCollection(order.
Id);
97 private void RemoveOrderFromCollection(
int orderId)
99 CancelPendingOrder cancelPendingOrderTrash;
100 _cancelPendingOrders.TryRemove(orderId, out cancelPendingOrderTrash);
103 private class CancelPendingOrder