private void OnThreadCapture() { bool bContinue = true; using (mydcamwait = new MyDcamWait(ref mydcam)) { while (bContinue) { DCAMWAIT eventmask = DCAMWAIT.CAPEVENT.FRAMEREADY | DCAMWAIT.CAPEVENT.STOPPED; DCAMWAIT eventhappened = DCAMWAIT.NONE; if (mydcamwait.start(eventmask, ref eventhappened)) { if (eventhappened & DCAMWAIT.CAPEVENT.FRAMEREADY) { int iNewestFrame = 0; int iFrameCount = 0; if (mydcam.cap_transferinfo(ref iNewestFrame, ref iFrameCount)) { MyUpdateImage(iNewestFrame); } } if (eventhappened & DCAMWAIT.CAPEVENT.STOPPED) { bContinue = false; } } else { if (mydcamwait.m_lasterr == DCAMERR.TIMEOUT) { // nothing to do } else if (mydcamwait.m_lasterr == DCAMERR.ABORT) { bContinue = false; } } } } }
public bool start(DCAMWAIT eventmask, ref DCAMWAIT eventhappened) { if (m_hwait == IntPtr.Zero) { m_lasterr = DCAMERR.INVALIDWAITHANDLE; } else { DCAMWAIT_START param = new DCAMWAIT_START(eventmask); param.timeout = m_timeout; m_lasterr = dcamwait.start(m_hwait, ref param); if (!m_lasterr.failed()) { eventhappened = new DCAMWAIT(param.eventhappened); } } return(!m_lasterr.failed()); }