I am currently using a simple button to open a webpage.

void ReportingClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.google.ca");
}

What I want to do is get it to open 3 pages at once with the one click and I am having a hard time getting it to work. I have tried multiple Process.start lines

void ReportingClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.google.ca");
System.Diagnostics.Process.Start("http://www.gmail.com");
System.Diagnostics.Process.Start("http://www.stackoverflow.com");
}

and even adding multiple pages into the handler.

void ReportingClick(object sender, EventArgs e)
{ 
System.Diagnostics.Process.Start("http://www.google.ca","http://www.gmail.com","http://www.s    tackoverflow.com")
}

It will only open the last page in the list in both cases. Any ideas?

有帮助吗?

解决方案

If IE is open, your code works fine and opens each link in a new tab, if not, I was able to make it work by making the app wait for 1 sec before calling the second page to open:

void ReportingClick(object sender, EventArgs e)
{
    System.Diagnostics.Process.Start("http://www.google.ca");
    System.Threading.Thread.Sleep(1000);
    System.Diagnostics.Process.Start("http://www.gmail.com");
    System.Threading.Thread.Sleep(1000);
    System.Diagnostics.Process.Start("http://www.stackoverflow.com");
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top