I have a program with only one form. By pressing a button it starts a ffmpeg conversion.
In the main form, in textboxes, ffmpeg stats are outputted. This is possible by taking StandardError output from ffmpeg.
Public Sub Console()
Dim Process As New Process
Process.StartInfo.UseShellExecute = False
Process.StartInfo.RedirectStandardError = True
Process.StartInfo.RedirectStandardOutput = True
Process.StartInfo.FileName = current_ffmpeg_path
Process.StartInfo.Arguments = input_params
Process.StartInfo.CreateNoWindow = True
Process.Start()
Dim ffmpeg_stats_output As System.IO.StreamReader = Process.StandardError
Do While Process.HasExited = False
[update all main form textboxes by taking input string from ffmpeg and elaborate it]
Loop
End Sub
The problem is that while this loop is executed the textboxes and progress bar are updated but the main form cannot be modified. There is in fact no control at all by user. So if I want to make a button to stop/pause ffmpeg in main form this cannot be pressed as anything else on the main form.
there is a way to maintain loops inside other Sub without loose control of main form while they're running?
I tried to fix it by calling another dialog form with textboxes and progress bar. But even this form loose completely control until the process is finished.
To send pause/stop conversion to ffmpeg (that runs without a window) is it correct use:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
SendKeys.Send("q")
SendKeys.Send("^s")
End Sub
or must be specified that this key is sent to the current running Process?
solved the problem with no control on main window...
just use a BackgroundWorker.