public void StartCapture(IEnumerable <string> devices, string outputFolder, string outputFormat, int clipLength, Action finished) { _outputFolder = outputFolder; _outputFormat = outputFormat; _clipLength = clipLength; SendStatus("Starting..."); Task.Run(() => { foreach (var id in devices) { var device = _devices.GetDevice(id); var handler = new CaptureHandler(device, _clipLength); _handlers.Add(handler); handler.OnFailure += OnFailure; handler.Activate(); } Main.Dispatcher?.BeginInvoke(DispatcherPriority.Normal, finished); }); }