Click here to Skip to main content
15,909,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLibtorrent Pin
Pwnagedo24-Sep-08 10:29
Pwnagedo24-Sep-08 10:29 
QuestionThreads and Memory Allocation Pin
Ylno24-Sep-08 8:10
Ylno24-Sep-08 8:10 
GeneralRe: Threads and Memory Allocation Pin
Perspx24-Sep-08 8:32
Perspx24-Sep-08 8:32 
AnswerRe: Threads and Memory Allocation Pin
Mark Salsbery24-Sep-08 9:37
Mark Salsbery24-Sep-08 9:37 
GeneralRe: Threads and Memory Allocation Pin
Ylno24-Sep-08 10:30
Ylno24-Sep-08 10:30 
GeneralRe: Threads and Memory Allocation Pin
Mark Salsbery24-Sep-08 10:49
Mark Salsbery24-Sep-08 10:49 
GeneralRe: Threads and Memory Allocation Pin
Ylno24-Sep-08 11:23
Ylno24-Sep-08 11:23 
AnswerRe: Threads and Memory Allocation Pin
Ylno24-Sep-08 11:48
Ylno24-Sep-08 11:48 
Ok,

I've implemented a heap clean up at the end of the code. Problem now is that when i call this function it waits untill the thread finishes until returning.
Can anyone see a way of perhaps having the code below return the address of the Thread and the pPulseData and have another code clean the memory for these two addresses.

Thanks

float LPTPulseThreaded(float aPortAddress, float aValue1, float aValue2, float aTime1, float aTime2,  float aTimes, float aControlAddress, float aOffOnValue){
	PDATA	pPulseData[1];	// Pointer to the funtion
	DWORD	dwThread[1];	
	HANDLE	hThread[1];		
	// Allocate memory for thread
	pPulseData[0] = (PDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DATA));
	// Populate the data struct	
	pPulseData[0]->PortAddress = aPortAddress; 
	pPulseData[0]->Value1 = aValue1;
	pPulseData[0]->Value2 = aValue2;
	pPulseData[0]->Time1 = aTime1; 
	pPulseData[0]->Time2 = aTime2;
	pPulseData[0]->Times = aTimes; 
	pPulseData[0]->ControlAddress = aControlAddress;
	pPulseData[0]->OffOnValue = aOffOnValue;
	//	Create the thread
	hThread[0] = CreateThread(NULL, 0,PulseThread, pPulseData, 0, &dwThread[0]);
	// Check to see if thread creation failed
	if(hThread[0] == NULL){return 1;}
	// Wait untill all threads have finished
	WaitForMultipleObjects(1, hThread, TRUE, 10000);
	// Free up the memory
	HeapFree(GetProcessHeap(), 0, pPulseData[0]);
	pPulseData[0] = NULL;

	return 0;
}

GeneralRe: Threads and Memory Allocation Pin
Mark Salsbery24-Sep-08 11:58
Mark Salsbery24-Sep-08 11:58 
GeneralRe: Threads and Memory Allocation Pin
Ylno24-Sep-08 12:22
Ylno24-Sep-08 12:22 
GeneralRe: Threads and Memory Allocation Pin
Mark Salsbery24-Sep-08 13:17
Mark Salsbery24-Sep-08 13:17 
QuestionMatrix to transform a vector MA to MB Pin
ybenaabud24-Sep-08 8:09
ybenaabud24-Sep-08 8:09 
AnswerRe: Matrix to transform a vector MA to MB Pin
CPallini24-Sep-08 8:34
mveCPallini24-Sep-08 8:34 
GeneralRe: Matrix to transform a vector MA to MB Pin
ybenaabud24-Sep-08 13:41
ybenaabud24-Sep-08 13:41 
GeneralRe: Matrix to transform a vector MA to MB Pin
ybenaabud24-Sep-08 13:46
ybenaabud24-Sep-08 13:46 
GeneralRe: Matrix to transform a vector MA to MB Pin
CPallini24-Sep-08 22:52
mveCPallini24-Sep-08 22:52 
GeneralRe: Matrix to transform a vector MA to MB Pin
ybenaabud25-Sep-08 11:35
ybenaabud25-Sep-08 11:35 
GeneralRe: Matrix to transform a vector MA to MB Pin
Rajesh R Subramanian28-Sep-08 19:32
professionalRajesh R Subramanian28-Sep-08 19:32 
GeneralRe: Matrix to transform a vector MA to MB Pin
CPallini28-Sep-08 21:50
mveCPallini28-Sep-08 21:50 
QuestionLoad a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 6:04
Cyrilix24-Sep-08 6:04 
AnswerRe: Load a Bitmap from a file (char array) stored in memory? Pin
led mike24-Sep-08 6:12
led mike24-Sep-08 6:12 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 7:34
Cyrilix24-Sep-08 7:34 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 9:44
Mark Salsbery24-Sep-08 9:44 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 10:21
Cyrilix24-Sep-08 10:21 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 10:45
Mark Salsbery24-Sep-08 10:45 

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.