Data var1;
//put values to the var1 members
StartThread(&va r1);
/*Data var2;
//put values to the var2members
StartThread(&va r2);
Data var3;
//put values to the var3 members
StartThread(&va r3);*/
I see var1 defined burt I do not see where you actually put data into the variable before you start your thread. Instead, I see a huge chunk of main()
inside your thread function (niskin). You define the variable outside the function and put information in it inside the function. That makes it a pointless argument. It also means your function is doing about 25 things. Functions shoule do about 1 thing.
Read your file., get your userid and password ands ftp command line and put that informattion in a Data variable. Then call StartThread using the address of that variable.
I say again from my Post #20, that your thread function should look like:
-
DWORD WINAPI niskin(LPVOID arg)
-
{
-
Data* ptr = reinterpret_cast<Data*> (arg);
-
//
-
//OK. Now ptr->userid is the userid
-
// ptr->password
-
// ptr->ftpcommandline
-
//
-
//TODO: Build a string using this stuff and call the system()
-
_popen("your ftp string does here");
-
}
-
In other words, your thread function should not have more than this in it.
Your current approach has you calling StartThread(), which launches a thread but then the thread function becomes a main(), complete with data entry.
You can't do this because when you launch a second thread, both threads will use the same ifstrream and they will trip over each other and cause your program to hang up.
When using threads, there can be
no information common to more than one thread unless you establish a thing called a critical section. As a beginner in threads, just make sure that no information is shared by more than one thread.
To sum up:
1) read your file
2) get the userid, password and ftp string
3) create a Data variable
4) put the userid, password and ftp string insid ethe Data variable
5) start yout thread (call StartThread())
6) repeats steps 1-5 until you have processed the entire file
7) etc..
and be sure your thread function (niskin) looks like my example.
Good Luck.