public int BatchReceiveAndSave(uint batchSize, uint?waitSeconds = null) { var result = 0; var list = queue.BatchReceive(batchSize, waitSeconds); if (null == list || !list.Any()) { return(result); } using (var trans = new TransactionScope()) { Parallel.ForEach(list, new ParallelOptions { MaxDegreeOfParallelism = 3 }, x => { Insert(x); }); trans.Complete(); result = list.Count; } return(result); }
public void Test_BatchReceive() { var data = queue.BatchReceive(16); Assert.Zero(data.Count); }