/*Summary * The callback routine delegated to handleException. */ private void ThreadException() { sw.Stop(); CaptureEventArgs args = new CaptureEventArgs(); args.BytesCaptures = 0; args.IsError = true; CaptureCompleted?.Invoke(this, args); xferRate = 0; XferBytes = 0; resultLength = 0; bRunning = false; }
private void RegisterCallbacks() { RegisterErrorCallback(); RegisterFocusStateChanged(); RegisterInterruptStartedCallback(); RegisterInterruptedCallback(); RegisterStateChangedCallback(); //Define capturing callback _capturingCallback = (IntPtr main, IntPtr postview, IntPtr thumbnail, IntPtr userData) => { Capturing?.Invoke(this, new CameraCapturingEventArgs(new StillImage(main), postview == IntPtr.Zero ? null : new StillImage(postview), thumbnail == IntPtr.Zero ? null : new StillImage(thumbnail))); }; //Define captureCompleted callback _captureCompletedCallback = _ => { SetState(CameraState.Captured); CaptureCompleted?.Invoke(this, EventArgs.Empty); }; }
/// <summary> /// Raises the <see cref="CaptureCompleted"/> event. /// </summary> /// <param name="e">The <see cref="Catel.Services.CameraOperationCompletedEventArgs"/> instance containing the event data.</param> protected void RaiseCaptureCompleted(CameraOperationCompletedEventArgs e) { CaptureCompleted?.Invoke(this, e); }
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 }