I am creating an application that when pressed will open a new tab in Chrome, and that tab will lead to a specific page that executes another function (I use threading because it needs time to execute the function on this page). Then closes the page. How would I be able to do so?
I would be thinking this code would work (google.com is obviously not the page).
var proc = Process.Start("chrome.exe", "google.com"); //open chrome tab.
Thread.Sleep(1000); //wait for the page to load and execute the function on the page
proc.Kill(); //remove tab
But, I get the error:
"An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
Additional information: Cannot process request because the process has exited."
As well, the tab does not close.