public void onDeleted(string sRowID, O2GRow rowData)
 {
     if (rowData.TableType == O2GTableType.Orders)
     {
         O2GOrderRow orderRow = (O2GOrderRow)rowData;
         if (mRequestIDs.Contains(orderRow.RequestID))
         {
             Console.WriteLine("The order has been deleted. Order ID: {0}", orderRow.OrderID);
             if (mBatchOrderMonitor != null)
             {
                 mBatchOrderMonitor.OnOrderDeleted(orderRow);
                 if (mBatchOrderMonitor.IsBatchExecuted())
                 {
                     PrintResult();
                     mResponseListener.StopWaiting();
                 }
             }
         }
     }
 }
        public void onTablesUpdates(O2GResponse data)
        {
            O2GResponseReaderFactory factory = mSession.getResponseReaderFactory();

            if (factory != null)
            {
                O2GTablesUpdatesReader reader = factory.createTablesUpdatesReader(data);
                for (int ii = 0; ii < reader.Count; ii++)
                {
                    switch (reader.getUpdateTable(ii))
                    {
                    case O2GTableType.Accounts:
                        O2GAccountRow account = reader.getAccountRow(ii);
                        //Show balance updates
                        Console.WriteLine("Balance: {0}", account.Balance);
                        break;

                    case O2GTableType.Orders:
                        O2GOrderRow order = reader.getOrderRow(ii);
                        switch (reader.getUpdateType(ii))
                        {
                        case O2GTableUpdateType.Insert:
                            if (mBatchOrderMonitor != null)
                            {
                                Console.WriteLine("The order has been added. Order ID: {0}, Rate: {1}, Time In Force: {2}",
                                                  order.OrderID,
                                                  order.Rate,
                                                  order.TimeInForce);
                                mBatchOrderMonitor.OnOrderAdded(order);
                            }
                            break;

                        case O2GTableUpdateType.Delete:
                            if (mBatchOrderMonitor != null)
                            {
                                Console.WriteLine("The order has been deleted. Order ID: {0}", order.OrderID);
                                mBatchOrderMonitor.OnOrderDeleted(order);
                                if (mBatchOrderMonitor.IsBatchExecuted())
                                {
                                    PrintResult();
                                    mSyncResponseEvent.Set();
                                }
                            }
                            break;
                        }
                        break;

                    case O2GTableType.Trades:
                        O2GTradeRow trade = reader.getTradeRow(ii);
                        if (reader.getUpdateType(ii) == O2GTableUpdateType.Insert)
                        {
                            if (mBatchOrderMonitor != null)
                            {
                                mBatchOrderMonitor.OnTradeAdded(trade);
                                if (mBatchOrderMonitor.IsBatchExecuted())
                                {
                                    PrintResult();
                                    mSyncResponseEvent.Set();
                                }
                            }
                        }
                        break;

                    case O2GTableType.ClosedTrades:
                        O2GClosedTradeRow closedTrade = reader.getClosedTradeRow(ii);
                        if (reader.getUpdateType(ii) == O2GTableUpdateType.Insert)
                        {
                            if (mBatchOrderMonitor != null)
                            {
                                mBatchOrderMonitor.OnClosedTradeAdded(closedTrade);
                                if (mBatchOrderMonitor.IsBatchExecuted())
                                {
                                    PrintResult();
                                    mSyncResponseEvent.Set();
                                }
                            }
                        }
                        break;

                    case O2GTableType.Messages:
                        O2GMessageRow message = reader.getMessageRow(ii);
                        if (reader.getUpdateType(ii) == O2GTableUpdateType.Insert)
                        {
                            if (mBatchOrderMonitor != null)
                            {
                                mBatchOrderMonitor.OnMessageAdded(message);
                                if (mBatchOrderMonitor.IsBatchExecuted())
                                {
                                    PrintResult();
                                    mSyncResponseEvent.Set();
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }