Exemple #1
0
        public void ShowProperties()
        {
            lock (startLocker)
            {
                if (reader == null || reader.IsDisposed)
                {
                    try
                    {
                        newSourceReader();
                    }
                    catch (Exception ex)
                    {
                        SharpDX.Utilities.Dispose(ref reader);
                        if (OnWorkerException == null)
                        {
                            throw ex;
                        }
                        OnWorkerException.Invoke(this, new ExceptionEventArgs(ex, ex.Message));
                        return;
                    }
                }

                if (settingsForm == null || settingsForm.IsDisposed)
                {
                    UpdatePropertiesCache();
                    settingsForm = new MF_CameraPropertiesForm(deviceName, getNativeMediaTypesAsStrings(), AMproperties);
                    settingsForm.SelectedMediaType      = MediaTypeID;
                    settingsForm.Transform              = OutputTransform;
                    settingsForm.OnTransformChanged    += SettingsForm_OnTransformChanged;
                    settingsForm.OnPropertyChanged     += SettingsForm_OnPropertyChanged;
                    settingsForm.OnSourceReaderChanged += SettingsForm_OnSourceReaderChanged;
                    settingsForm.SetReaderCheckBoxes(EnableAdvancedVideoProcessing, EnableHardwareTransform);
                }
            }

            settingsForm.Show();
            settingsForm.BringToFront();
        }
Exemple #2
0
        private async void startSamplerTask()
        {
            kickstartEvent.Set();
            try
            {
                lock (startLocker)
                {
                    if (samplerTask?.Status == TaskStatus.Running)
                    {
                        return;
                    }

                    if (WantToConfigureReader || reader == null || reader.IsDisposed)
                    {
                        newSourceReader();
                        WantToConfigureReader = false;
                        WantToChangeMediaType = true;
                    }

                    samplerTask?.Dispose();
                    cancelTokenSource?.Dispose();
                    cancelTokenSource = new CancellationTokenSource();
                    samplerTask       = new Task(samplerProc, cancelTokenSource.Token);
                    samplerTask.Start();
                }
                //Sampler Task should eventually be awaited so that exceptions that may have been thrown can be handled
                await samplerTask;
            }
            catch (Exception ex)
            {
                if (OnWorkerException == null)
                {
                    throw ex;
                }
                OnWorkerException?.Invoke(this, new ExceptionEventArgs(ex, ex.Message));
            }
        }