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

C / C++ / MFC

 
QuestionMulti threads to download http file---please help me! Pin
victording27-May-07 22:32
victording27-May-07 22:32 
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 
Hi every one,
now I want to build a module about download http file with mylti 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.
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 
AnswerRe: How to remove the selected temporary internet files programmatically? Pin
Hamid_RT28-May-07 1:57
Hamid_RT28-May-07 1:57 
GeneralRe: How to remove the selected temporary internet files programmatically? Pin
Mushtaque Nizamani31-May-07 20:52
Mushtaque Nizamani31-May-07 20:52 
GeneralRe: How to remove the selected temporary internet files programmatically? Pin
Hamid_RT1-Jun-07 1:28
Hamid_RT1-Jun-07 1:28 
QuestionConvert a text file in DOS mode to UNIX mode Pin
askmeby27-May-07 21:43
askmeby27-May-07 21:43 
AnswerRe: Convert a text file in DOS mode to UNIX mode Pin
kakan27-May-07 22:00
professionalkakan27-May-07 22:00 
AnswerRe: Convert a text file in DOS mode to UNIX mode Pin
CPallini27-May-07 22:00
mveCPallini27-May-07 22:00 
QuestionHow to save .doc (MS Word File ) in MySQL Database Pin
Y_Kaushik27-May-07 21:15
Y_Kaushik27-May-07 21:15 

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.