Start New Discussion within our Software Development Community

Hi All,
Why my QueueUserWorkItem is not at all working. My code is here:

typedef struct
{
    PCHAR URL[MAX_URL] ;
    PCHAR DestinationPath ;
}MAINDATA, *PMAINDATA ;
 
int main(int argc, char * argv[])
{
	PMAINDATA	pData ;
		
	BOOL bQuwi ;
	DWORD dwIndex ;
	PCHAR pURL ;
 
        pData = (PMAINDATA)malloc(sizeof(MAINDATA)) ;
	pData->DestinationPath = NULL ;
	pData->URL[0] = 0 ;
 
        do
	{
	
		if(argc < 3)
		{
			printf("Main Error-> Not Enough Arguments\n") ;
			break ;
		}
		printf("START\n") ;
		pData->DestinationPath = argv[2] ;
		while((pURL = (PCHAR)GetNext_FileList(pContext)) != NULL)
		{
			TempURL = StrDupA(pURL) ;
			pData->URL[dwIndex] = (PCHAR)TempURL ;
			dwIndex++ ;
		}
		dwTotalNumberOfURL = dwIndex ;
 
		bQuwi = QueueUserWorkItem(MyThreadProc,(PVOID) pData,      
                                                             WT_EXECUTEDEFAULT) ;
		if ( !bQuwi )
			printf("Main: QueueUserWorkItem Failed\n");
 
		printf("SUCCESS\n") ;
	
	}while(FALSE) ;
        return 0 ;
}
 
DWORD CALLBACK MyThreadProc( LPVOID lpParam ) 
{ 
    PMAINDATA pData ;
    
	pData = (PMAINDATA)lpParam ;
 
	DownloadFile(pData->URL, pData->DestinationPath) ;
    
    return 0 ; 
}

I have not submitted the whole code. So please bypass the declaration and free memory errors. The only problem I am facing is that QUWI is not calling my "MyThreadProc" function although it is returning TRUE.

This article has been dead for over six months. Start a new discussion instead.