Пример #1
0
        public void ProcessBatch(object tsacs)
        {
            TransactionQueue queue = (TransactionQueue)tsacs;
            int BatchID            = queue.BatchID;

            foreach (Transaction item in queue)
            {
                ProcessTransaction(item, BatchID);
            }
        }
Пример #2
0
        public void Start(TransactionQueue tsacs)
        {
            WaitCallback callBack;

            System.Diagnostics.Debug.WriteLine("Setting minimum threads for pool");
            System.Threading.ThreadPool.SetMinThreads(10, 10);
            TransactionQueue splitchunk = new TransactionQueue();

            callBack      = new WaitCallback(ProcessBatch);
            MasterAccount = tsacs.Queue[0].AccountFrom;
            for (int i = 1; i <= tsacs.Queue.Count; i++)
            {
                splitchunk.Add(tsacs.Queue[i - 1]);
                if (i % 500 == 0 || i == tsacs.Queue.Count)
                {
                    splitchunk.BatchID = tsacs.BatchID;
                    System.Threading.ThreadPool.QueueUserWorkItem(callBack, (object)splitchunk);
                    splitchunk = null;
                    splitchunk = new TransactionQueue();
                }
            }
        }