When I try to stop video capture on the FormClosing Event in a WinForms application. I always get this exception:
"Invoke or BeginInvoke cannot be called on a control until the window handle has been created"
Here's the code:
private async void PictureDialog_FormClosing(object sender, FormClosingEventArgs e)
{
if (_captureCore.State() != PlaybackState.Free)
await _captureCore.StopAsync();
if (File.Exists("output.mp4"))
File.Delete("output.mp4");
}
Is there a better way of handling the window closing and stopping the video? I noticed that the camera and file are still "in use" even after the form is destroyed.
Hello,
When I try to stop video capture on the FormClosing Event in a WinForms application. I always get this exception: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created"
Here's the code:
private async void PictureDialog_FormClosing(object sender, FormClosingEventArgs e) { if (_captureCore.State() != PlaybackState.Free) await _captureCore.StopAsync(); if (File.Exists("output.mp4")) File.Delete("output.mp4"); }
Is there a better way of handling the window closing and stopping the video? I noticed that the camera and file are still "in use" even after the form is destroyed.
Thanks