Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

screen output delayed

Status
Not open for further replies.

barryp

Programmer
Jan 30, 2002
48
GB
Hi
I've been trying to find out why the following code's output is delayed 'till all the processing is completed. I see the first line in the ListBox but then the rest don't appear till the end.


void CAddDialog::OnOK()
{
STARTUPINFO startup;
PROCESS_INFORMATION procinfo;
CString command, fullname;

BeginWaitCursor();

for(int index1=0; index1<array1.GetSize(); index1++)
{
m_listbox.AddString("ZIPPING " + theFilePath + "\\" + array1[index1].sourcename);
m_listbox.Invalidate();
m_listbox.UpdateWindow();

::ZeroMemory(&startup, sizeof(startup));

startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW ;
startup.wShowWindow = SW_HIDE; // hidden console window
command.Format("\"c:\\Program Files\\PKWARE\\pkzipc\\pkzipc\" -add \"%s\\%s.zip\" -overwrite \"%s\\%s\"", theLibPath, array1[index1].zipname, theFilePath, array1[index1].sourcename);
LPTSTR cmd = command.GetBuffer(command.GetLength() + 1);
BOOL started = ::CreateProcess(NULL, // command is part of input string
cmd, // (writeable) command string
NULL, // process security
NULL, // thread security
TRUE, // inherit handles flag
0, // flags
NULL, // inherit environment
NULL, // inherit directory
&startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION
if(!started) {
DWORD err = ::GetLastError(); // preserve across CloseHandle calls
SetDlgItemText(IDC_LIBPATH,cvError(err));
}

DWORD waitresult;
do{
m_listbox.Invalidate();
m_listbox.UpdateWindow();
waitresult = WaitForSingleObject(procinfo.hProcess, 100);
}while(waitresult == WAIT_TIMEOUT);

// Close process and thread handles.
CloseHandle( procinfo.hProcess );

}
}
 
PostScript

Itseems to be the processing (ZIPPING) of a large file that causes the log-jamb

A dozen small files work fine - the messages appearing in reasonable time & order

Stick one large filr into the mix & all's well till this one is encountered then no more text appears in the ListBox until all files have been processed

Barry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top