System.Diagnostics.Process overwrites windows.

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;
}
}
}
}
 
V

VJ

tried about 10 times, it all opened in new window or Tabs, I have FireFox as
my default browser

Interesting a property called CreateNoWindow -> tells to create a new
windows.. uhm. that threw me of for a bit.. but anyways, seems to work..
with FireFox as default browser

VJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top