I wrote this code:
Process Processs = Process.GetProcessesByName("ProcessName")[0];
do
{
await Task.Delay(1500);
}
while (!(Processs.MainWindowHandle != IntPtr.Zero));
// stuff to do here
Processs = (Process)null;
But I get an error
index was outside the bounds of the array
Can anyone help me fix it? Or write new, better code?