I have a WinForms application that starts a wpf process using Process.Start. I would like to know when the WPF process is finished and I can access the property process.MainWindowHandle(its 0 until it is fully loaded).
I tried polling, but the descriptor is always 0. However, if I debug and wait (after Process.Start) for the WPF application to load, then I get the correct descriptor.
Does not work:
int maxCount=100000;
int count=0;
do
{
wpfProcess.WaitForInputIdle();
_hWnd = net4ReconProcess.MainWindowHandle;
count++;
} while (_hWnd.ToInt32() == 0 || count > maxCount);
source
share