Reputation: 4737
I have a single form and I need to duplicate it 200 times so they all together will do the processing. My form is simply taking screenshots of websites and i want to clone it many times to get a faster result. Is it possible or what is the best way for it? Should I keep on searching duplicating a form or should I find a way to open the exe file 200 times?
Upvotes: 0
Views: 134
Reputation: 48096
I would create another project which is nothing more than a loop which kicks off 200 instances of this process.
for (int i = 0; i < 200; i++)
Process.Start(@"C:\path\to\webcrawler.exe");
If you need to pass some data into it make is so webcrawler accepts some command line parameters and start a command line process passing it "webcrawler.exe args" instead.
Upvotes: 1
Reputation: 17327
If your code uses the WebBrowser
control to open pages and then grab a screenshot (as I assume you do), I'd recommend just opening your .exe so many times and then running the instances in parallel. This at least gives you a separate process for each browser control so all those instances will only compete for network resources but the rest will be in separate processes.
Running 200 instances is almost guaranteed to be a bad idea - 200 forms with controls will use a lot of system resources. Unless you have a very powerful computer you'll have issues. Running around 50 instances will likely be better (you may have to experiment to find a sweet spot - it may be more than 50, I'm just guesstimating).
It's not an elegant solution by any means but I assume this is for a utility, not for end users.
Upvotes: 0