public bool StartPhosphorescenceMeasurement(double delay, uint count, Callback whenMeasurementEnds, out string error) { bool result = false; error = ""; try { if (!_cameraConnected) { throw new Exception("Camera not connected"); } Ready = false; //stop streaming camera _ptGreyCamera.StopVideo(); //increase frame buffer count if (!_ptGreyCamera.SetStreamBufferCount(100)) { throw new Exception("Could not set frame buffer count"); } //do this before we change trigger mode _phosStartTimestamp = _ptGreyCamera.GetImageTimeStamp(); //empty phos image buffer _phosImages.Clear(); _phosFilteredImages.Clear(); //enable external trigger with count if (!_ptGreyCamera.PhosTriggerMode(true, count)) { throw new Exception("Could not set trigger mode"); } //enable delay if (!_ptGreyCamera.TriggerDelay(true, delay)) { throw new Exception("Could not set delay"); } //set phos count _phosImagesToCollect = count; //start video _ptGreyCamera.StartVideo(false); //start backgroundworker to wait for completion BWArgument arg; arg.measurementEnd = whenMeasurementEnds; arg.waitTime = (int)(10000 + (count * Shutter + delay)); _phosMeasureCompletionEvent.Reset(); BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += WaitForPhosCompletion; bw.RunWorkerCompleted += PhosMeasurementComplete; bw.RunWorkerAsync(arg); result = true; } catch (Exception ex) { error = ex.Message; Ready = true; _ptGreyCamera.StopVideo(); _phosImagesToCollect = 0; _phosMeasureCompletionEvent.Set(); _ptGreyCamera.TriggerDelay(false, 0); _ptGreyCamera.PhosTriggerMode(false, 0); _ptGreyCamera.StartVideo(); } return(result); }