CreateProcess Loop Problem (Visual C++ 2005)

W

wtfdan

When I call the method perform_single_upload() in this loop:

----------------------------
private: System::Void start_uploads(int i)
{
i = 0;
while(i < master_list->Length)
{
//Create a single batch file containing the upload instructions
create_single_upload(i);
//Increment loading bar
pb_Progress->Value::set(pb_Progress->Value::get() + 1);

//Load and perform the batch file contents
perform_single_upload();
//Increment loading bar
pb_Progress->Value::set(pb_Progress->Value::get() + 1);

//Delete the batch file in preparation for the next one
cleanup_upload();
//Increment loading bar
pb_Progress->Value::set(pb_Progress->Value::get() + 1);

i++;
}
}
----------------------------

With perform_single_upload() doing the following:

----------------------------
STARTUPINFO si;
PROCESS_INFORMATION pi;
LPTSTR szCmdline=_tcsdup(TEXT("upload.bat"));

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line)
szCmdline, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
//Something went wrong.
AnError^ uploaderror = gcnew AnError();

uploaderror->label1->Text::set("There was an error finding a batch
script file.");
uploaderror->ShowDialog();
return;
}

// Wait until child process exits.
WaitForSingleObject(pi.hProcess, INFINITE);

// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
----------------------------

....my main process appears frozen until the loop in the first method
has gone through all of its iterations. I can't seem to figure out
why it doesn't update anything after calling the
perform_single_upload() method for the first time.

Is there any way to maintain control of my main application after a
CreateProcess(), or system(), or WinExec(), etc. call?
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top