Click here to Skip to main content
15,922,166 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhelp please! Pin
ginjikun27-May-07 22:45
ginjikun27-May-07 22:45 
AnswerRe: help please! Pin
Y_Kaushik27-May-07 23:03
Y_Kaushik27-May-07 23:03 
GeneralRe: help please! Pin
ginjikun27-May-07 23:45
ginjikun27-May-07 23:45 
GeneralRe: help please! Pin
Stephen Hewitt28-May-07 17:35
Stephen Hewitt28-May-07 17:35 
GeneralRe: help please! Pin
ginjikun29-May-07 18:29
ginjikun29-May-07 18:29 
QuestionCreate uninstall program Pin
Md. Mazharul Islam Khan27-May-07 22:45
Md. Mazharul Islam Khan27-May-07 22:45 
AnswerHow to Create uninstall program??? Pin
Md. Mazharul Islam Khan27-May-07 23:25
Md. Mazharul Islam Khan27-May-07 23:25 
QuestionMulti threads to download http file---please help me! Pin
victording27-May-07 22:32
victording27-May-07 22:32 
Hi every one,
now I want to build a module about download http file with multi thread.
I create several threads.Following is my code:

DWORD CMyThread::Execute( )
{
CInternetSession session;
CHttpFile* phttpFile = (CHttpFile*)session.OpenURL( m_strHttpFile,1,INTERNET_FLAG_TRANSFER_BINARY

|INTERNET_FLAG_RELOAD );
phttpFile->Seek( m_beginPosition,0 );//m_beginPosition is the position of http file that this thread begin to read
CFile localFile;
if( FALSE == localFile.Open(szLocalFileName,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary,NULL))
{
return 0;
}
int readlen = -1;
BYTE buffer[1024];
int nTotalReadLen = 0;
while( 1 )
{
readlen = phttpFile->Read( buffer,1024 );//the second thread can't be running here until the first thread finished.
localFile.Write( buffer,1024 );
nTotalReadLen += readlen;
if( nTotalReadLen == m_size )//finish download the part,m_size is the part of the total size
{
localFile.Close( );
phttpFile->Close();
session.Close();
m_pFileDownLoader->SendMessage( T_MESSAGE_READ_FINISHED );
break;
}

}
}
but only the first one can running smoothly.the second stop in "pHttpFile->Read( )".but It can retrieve running Until the first finished.
How can I make the threads running at the same time?I am a fresh man in web programe ,If you have the instance about this ,please give me.thanks a lot.
QuestionCheck Numeric value Pin
garfield18527-May-07 22:30
garfield18527-May-07 22:30 
AnswerRe: Check Numeric value Pin
_AnsHUMAN_ 27-May-07 22:38
_AnsHUMAN_ 27-May-07 22:38 
AnswerRe: Check Numeric value Pin
Anurag Gandhi27-May-07 22:45
professionalAnurag Gandhi27-May-07 22:45 
AnswerRe: Check Numeric value Pin
garfield18527-May-07 22:57
garfield18527-May-07 22:57 
GeneralRe: Check Numeric value Pin
_AnsHUMAN_ 28-May-07 0:05
_AnsHUMAN_ 28-May-07 0:05 
AnswerRe: Check Numeric value Pin
Lane Yu27-May-07 23:57
Lane Yu27-May-07 23:57 
QuestionProblem in "multi thread to download http file",thanks! Pin
victording27-May-07 22:27
victording27-May-07 22:27 
Questionabout SendMessage Pin
mt_samiei27-May-07 22:07
mt_samiei27-May-07 22:07 
AnswerRe: about SendMessage Pin
CPallini27-May-07 22:51
mveCPallini27-May-07 22:51 
JokeRe: about SendMessage Pin
Rajesh R Subramanian28-May-07 1:08
professionalRajesh R Subramanian28-May-07 1:08 
GeneralRe: about SendMessage Pin
CPallini28-May-07 1:36
mveCPallini28-May-07 1:36 
JokeRe: about SendMessage Pin
Hamid_RT28-May-07 1:59
Hamid_RT28-May-07 1:59 
AnswerRe: about SendMessage Pin
nitin328-May-07 0:30
nitin328-May-07 0:30 
AnswerRe: about SendMessage Pin
Hamid_RT28-May-07 1:13
Hamid_RT28-May-07 1:13 
QuestionHow to block Alt+F4 for a dialogbox Pin
Neo Andreson27-May-07 21:51
Neo Andreson27-May-07 21:51 
AnswerRe: How to block Alt+F4 for a dialogbox Pin
Rajesh R Subramanian27-May-07 22:07
professionalRajesh R Subramanian27-May-07 22:07 
QuestionHow to remove the selected temporary internet files programmatically? Pin
Mushtaque Nizamani27-May-07 21:50
Mushtaque Nizamani27-May-07 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.