Running multiple copies of same program
I have a simple form that has 4 textboxes, that controls where the program is going to search for data. When the program is run and the form is filled in the program goes about searching for the data. To speed up the operation(online) I run the same program multiple times changing just one of the textboxes, the rest remain the same. It's just a simple matter of changing one number to change where it's suppose to look.
Is it possible to have one overseeing program where I only have to fill out the form once and it will automatically run multiple copies of the .exe file.
Re: Running multiple copies of same program
Re: Running multiple copies of same program
One of the biggest issues running multiple copies of the same program is dealing with saving variables and "restarting where you left off".
For example if you start a single copy of the program and it loads variable X, and the user modifies variable X and saves its value for the next time you start the program, all is well. However, if you start multiple copies which are also going to utilize variable X -- the value of value X will be either the original X value or some modified X value that the user saved prior to the second copy being started.
If this is not an issue with your program, ignore the above, if it is and you find a "good" solution, I'd also like to know.
Re: Running multiple copies of same program
Quote:
Originally Posted by
hijack
Is it possible to have one overseeing program where I only have to fill out the form once and it will automatically run multiple copies of the .exe file.
Yes, you can have a "Teacher" program that hands out work to multiple "Student" programs.
Basically the "Teacher" uses something like ShellExecute, passing the "unit of work" as a Command Line Parameter, to start the "Student" .exe.
If you have 'complications' such as described by dw85745 it's a fairly simple matter for the "Teacher" to remember which "units of work" have beeen handed out and which are incomplete. It can then schedule other "Students" to complete the tasks as and when required.
Communication from the "Student" back to the "Teacher" could be done via an IPC or by planting files with certain names (eg the "unit of work") in certain Folders.
Re: Running multiple copies of same program
Doogle:
What I was getting at -- was where you have a very large program which uses a database to store startup values. You can use a "number of exes copy counter" then copy the whole database to a temporary location and then destroy the database as each associated (the counter number) "exe" is terminated. Got a better solution?
Re: Running multiple copies of same program
Quote:
Originally Posted by
dw85745
One of the biggest issues running multiple copies of the same program is dealing with saving variables and "restarting where you left off".
For example if you start a single copy of the program and it loads variable X, and the user modifies variable X and saves its value for the next time you start the program, all is well. However, if you start multiple copies which are also going to utilize variable X -- the value of value X will be either the original X value or some modified X value that the user saved prior to the second copy being started.
If this is not an issue with your program, ignore the above, if it is and you find a "good" solution, I'd also like to know.
Use a counter saved as a txt file...if I'm understanding you correctly. What I have is a simple problem right now of VERY limited internet access. Pretty much have lost routine access at home so I'm trying to maximize what I can done when I get away from home. Fortunately, right now I do have it at home, very intermittently(sp?). I don't foresee that changing anytime soon though.
My program is downloading video files that are saved using randomly generated numbers. They fall in a pattern so downloading them is pretty simple. They use a 10 digit number, ie 1234567890. What I have my program setup to do is have me type in the first 4 numbers in the top box. In the next two boxes I type in the range I want to search for as the fifth number...generally over a week or so they will run through 5-6 numbers on the fifth digit, roughly one a day but sometimes the days get lumped together into one. Then I have it so I type the sixth number in the fourth box. From there when I hit the download button it starts searching through the website looking for matches and when it finds one it downloads it.
For example:
Top box: 1234
2nd box: 0
3rd box: 5
4th box: 1
Naturally each of the first four digits remain constant. The next digit is the first one to change. It cycles through 010000, 110000, 210000, 310000, 410000, 510000. Then it goes out and increase the last digit by one and repeats the same procedure, 010001, 110001, 210001, 310001, 410001, 510001. It keeps on increasing through the last 4 digits on up until it hits 9999 then the program quits.
I have it so after it has searched a particular number it automatically saves the number in the file that corresponds with the fifth digit, ie 12340.txt 12341.txt, 12342.txt, 12343.txt, 12344.txt, 12345.txt. It saves the entire 10 digit number. This way if I lose internet connection, electricity, etc. I have the known starting place for the next time I run the program.
Nothing right now would be getting reported back to the main program. As I say that though, I have thought about trying to have the main program 'sense' when all the running copies is finished and have it find what the highest number was that had been downloaded and set everything up to start from there in the future. I haven't even tried to do that yet since I don't have the Teacher/Master program up and running. Admittedly, I know I could easily write a separate subroutine(meun option) that would check through the folder where the files are stored and find the highest number listed and set everything accordingly as well. That would probably be the simplest/smartest way.
Generally I don't run more than 5 copies of the program at once to keep from bogging down the internet connection too much. Right now I'm only running two copies to try to keep it from bogging down on me.
What I'm wanting is a way so I don't have to run the same program 2-10 times to get the same results for pretty much the same inputted data. I have a feeling I'm going to have to modify my initial program slightly so I don't end up running into timeout routines on some of the wifi services I use when I'm not at home.
I'll have to do some looking around on ShellExecute since that is something I have no knowledge of at all.
Thanks guys.
Re: Running multiple copies of same program
Why do you need to run multiple copies of the same program, why isn't one instance enough?
Re: Running multiple copies of same program
If I was doing everything right from the computer, aka hard drive access I would agree with you. Online when you can have several connections open at once and running at the same time you can get a lot more accomplished, especially when you are spending most of that time 'searching' versus downloading.
Re: Running multiple copies of same program
Try This:
Dim text1 = New String(TextBox1.Text)
Dim text2 = New String(TextBox2.Text)
Dim text3 = New String(TextBox3.Text)
Dim text4 = New String(TextBox4.Text)
Dim f = New Form1
f.Show()
f.TextBox1.Text = text1
f.TextBox2.Text = text2
f.TextBox3.Text = text3
f.TextBox4.Text = text4
Re: Running multiple copies of same program
Quote:
Originally Posted by
rqmok
Try This:
Dim text1 = New String(TextBox1.Text)
...
You are in the wrong forum, we don't do VB.Net here.
1 Attachment(s)
Re: Running multiple copies of same program
I had a play with my idea regarding 'Master' / 'Student' and have created a simulation of what I think you're trying to do.
In the attached are two projects, one for the 'Master' and one for the 'Student'. Basically the 'Master' maintains a file containing details about the last Task scheduled together with any tasks that have previoiusly failed. When run, any previously failed tasks are scheduled and a new set of tasks scheduled starting at the last scheduled task + 1.
For the simulation, the 'Student' just sleeps for a random amount of time before reporting back to the 'Master'. Also a 'Student' may fail at random, in which case it reports the failure and will be re-scheduled in the next run of the 'Master'
I've used Winsock as the IPC (since I'm comfortable using it, and it also give the opportunity, with a bit of tweaking, for the 'Student' to run on multiple machines)
You may like to have a play and see if it's of any use. Just compile and make the Student and run the Master. You may have to change some of the constants in the Master code to reflect the location of the Student program.
@dw85745: BTW it may also give you some ideas but if not then perhaps you could start a new thread with your requirements.
Re: Running multiple copies of same program
I justgot the chance to get online to see your posting Doogle. I downloaded and will take a look at it when I get back home. Now to take benefit of a high speed connection with several different things I'm trying to get done today. Hopefully your project will give me a few new ideas that might help out another project I'm working on as well. I haven't ever seen IPC being used before so it will help in furthering my knowledge.
I'll report back hopefully within a couple of days and let you know.
Re: Running multiple copies of same program
Doogle,
I see for complete understanding I do need to get an education in winsocks and tcp. Most of it I can follow through and I am already seeing the logic of using something like this with another program I've also been working on right now. I do have a couple of questions based on what I saw in the code you provided...a couple of things I've never seen done this way before and I just want to make sure that I understand the usage of the code.
The reasoning for using that...I'm totally lost. I've seen it used maybe once before.
Code:
Open MyFile For Random As intFile Len = 13
I thought you had to specify when opening a file as to whether it was for input/output/read/write/append. Can the Random do either or? At the same time can you use Input/Get or Output/Print with it? I've never seen Random used before in an Open statement.
Len = 13
I also have never seen this used before. Do I understand it correctly that you can specify how long the file can be? I didn't know you could do that.
I still have more looking into it to do as I haven't had much of a chance to look at the Student yet. Hopefully by the time the weekend is over if not sooner I'll be able to get back to it and dig much deeper...maybe with a bit better understanding as well.
Thanks.
Re: Running multiple copies of same program
Randomize - This is used to seed the Random Number Generator. That has nothing to do with the problem you were having, I used that to create the random sleep times and random aborts.
Opening a file for Random Access allows you to read and write to the file. It is different from a 'straightforward' file in as much as you read and write to particular records. The 'Len =' tells the I/O sub-system how long each record is (they have to be of a fixed length). In the case of my example, each record is 13 bytes long. In the example code, each student has a particular ID such that data coming from, say Student 3, was written to record number 3 of the file. You can only use Put and Get when using Random access.