private void SnapshotRetriever_CameraThumbnailProduced(object sender, CameraThumbnailProducedEventArgs e) { SnapshotRetriever retriever = sender as SnapshotRetriever; if (retriever != null) { retriever.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced; snapshotting.Remove(retriever.Identifier); } OnCameraThumbnailProduced(e); }
public override void GetSingleImage(CameraSummary summary) { if (snapshotting.IndexOf(summary.Identifier) >= 0) { return; } // Spawn a thread to get a snapshot. SnapshotRetriever retriever = new SnapshotRetriever(summary, deviceIndices[summary.Identifier]); retriever.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced; snapshotting.Add(summary.Identifier); ThreadPool.QueueUserWorkItem(retriever.Run); }
public override void StartThumbnail(CameraSummary summary) { SnapshotRetriever snapper = snapshotting.FirstOrDefault(s => s.Identifier == summary.Identifier); if (snapper != null) { return; } snapper = new SnapshotRetriever(summary, deviceIndices[summary.Identifier]); snapper.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced; snapshotting.Add(snapper); snapper.Start(); }
public override void StopAllThumbnails() { for (int i = snapshotting.Count - 1; i >= 0; i--) { SnapshotRetriever snapper = snapshotting[i]; snapper.Cancel(); snapper.Thread.Join(500); if (snapper.Thread.IsAlive) { snapper.Thread.Abort(); } snapper.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced; snapshotting.RemoveAt(i); } }
private void ProcessThumbnail(object sender, CameraThumbnailProducedEventArgs e) { SnapshotRetriever snapper = sender as SnapshotRetriever; if (snapper == null) { return; } log.DebugFormat("Received thumbnail event for {0}. Cancelled: {1}.", snapper.Alias, e.Cancelled); snapper.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced; if (snapshotting.Contains(snapper)) { snapshotting.Remove(snapper); } OnCameraThumbnailProduced(e); }