private unsafe void XferData(byte[][] cBufs, byte[][] xBufs, byte[][] oLaps) { int k = 0; int len = 0; XferBytes = 0; sw.Restart(); while (bRunning) { // WaitForXfer fixed(byte *tmpOvlap = oLaps[k]) { OVERLAPPED *ovLapStatus = (OVERLAPPED *)tmpOvlap; if (!bulkInEndPoint.WaitForXfer(ovLapStatus->hEvent, 500)) { bulkInEndPoint.Abort(); PInvoke.WaitForSingleObject(ovLapStatus->hEvent, CyConst.INFINITE); } } // FinishDataXfer if (bulkInEndPoint.FinishDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k])) { XferBytes += len; } k++; if (k == QueueSz) // Only update displayed stats once each time through the queue { k = 0; xferRate = (sw.ElapsedMilliseconds > 0) ? ((long)XferBytes / sw.ElapsedMilliseconds) : (long)XferBytes; if (!continousMode) { sw.Stop(); bRunning = false; } /*if (continousMode) * { * Array.Clear(resultBuffer, 0, BufSz * QueueSz); * }*/ for (int i = 0; i < xBufs.Length; i++) { Array.Copy(xBufs[i], 0, resultBuffer, BufSz * i, BufSz); } resultLength = (long)XferBytes; CaptureEventArgs args = new CaptureEventArgs(); args.BytesCaptures = resultLength; args.IsError = false; syncContext.Post(e => CaptureCompleted?.Invoke(this, args), args); if (continousMode) { Thread.Sleep(1); } } if (continousMode) { len = BufSz; Array.Clear(xBufs[k], 0, BufSz); bulkInEndPoint.BeginDataXfer(ref cBufs[k], ref xBufs[k], ref len, ref oLaps[k]); } } // End infinite loop }