public void Retrieve() { if (!_alreadyRetrieved) { //construct this object before the lock so there's no chance of deadlocking //with the parent data source (because we are accessing it's tags at the //same time as it's trying to get the pixel data). var retriever = new FramePixelDataRetriever(this); lock (_syncLock) { if (!_alreadyRetrieved) { AbortAttemptIfNecessary(); try { ResetAttemptData(); _retrievesAttempted++; var start = DateTime.Now; _framePixelData = retriever.Retrieve(); var end = DateTime.Now; _lastRetrievePerformanceInfo = new StreamingPerformanceInfo(start, end, _framePixelData.BytesReceived); _alreadyRetrieved = true; } catch (Exception ex) { _lastError = ex; throw; } } } } }