G
Greg
Hi,
I am trying to use the System.Diagnostics.Process namespace to open up
some windows in a browser dynamically. The urls I want to open are
sent to a function in a generic string list. When I loop through
these urls and open them, sometimes they all open, sometimes only 2
open (but really all have opened, only 1 has been overwritten).
I have created the following sample to make sure it wasn't just the
context of my code and the same thing happens, sometimes the windows/
urls overwrite each other (which is not what I want). They should
each open in their own tab or window. I have tried
StartInfo.CreateNoWindow = true and this not helped either.
If you run the following code you might see all 3 open but you should
see them overwriting at some point.
I am stumped on how to do this cleaning and reliably all the time.
Any help would be appreciated.
Greg
The code;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
namespace ProcessTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<string> m_urls = new List<string>();
m_urls.Add("http://www.cnn.com");
m_urls.Add("http://www.google.com");
m_urls.Add("http://www.msn.com");
foreach (string url in m_urls)
{
Process process = new Process();
process.Refresh();
process.StartInfo.FileName = (url.ToString());
process.Start();
process.Refresh();
process = null;
}
}
}
}
I am trying to use the System.Diagnostics.Process namespace to open up
some windows in a browser dynamically. The urls I want to open are
sent to a function in a generic string list. When I loop through
these urls and open them, sometimes they all open, sometimes only 2
open (but really all have opened, only 1 has been overwritten).
I have created the following sample to make sure it wasn't just the
context of my code and the same thing happens, sometimes the windows/
urls overwrite each other (which is not what I want). They should
each open in their own tab or window. I have tried
StartInfo.CreateNoWindow = true and this not helped either.
If you run the following code you might see all 3 open but you should
see them overwriting at some point.
I am stumped on how to do this cleaning and reliably all the time.
Any help would be appreciated.
Greg
The code;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
namespace ProcessTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<string> m_urls = new List<string>();
m_urls.Add("http://www.cnn.com");
m_urls.Add("http://www.google.com");
m_urls.Add("http://www.msn.com");
foreach (string url in m_urls)
{
Process process = new Process();
process.Refresh();
process.StartInfo.FileName = (url.ToString());
process.Start();
process.Refresh();
process = null;
}
}
}
}