Unix to Windows Porting Dictionary for HPC |
||
|
|
||
|
|
LinksFunction List
|
Table of Contents header file: Windows.h
DWORD WINAPI WaitForSingleObject(
__in HANDLE hHandle,
__in DWORD dwMilliseconds
);
The pthread_join function is used to synchronize a main thread with the termination of a child thread. If the value_ptr is not null, the exit code from the child will be returned in that location. The Windows equivalent function is effectively the same as the POSIX version. The function returns the child termination code as a DWORD. The Windows call has the added ability of a timed wait. If the value of dwMilliseconds is zero, the parent thread will not wait. If the value is Infinite the effect will be the same as the Unix call. If a parent thread wants to wait for the termination of multiple children, you can use WaitForMultipleObjects instead.
#include "stdafx.h"
#include <time.h>
#include <windows.h>
#include <iostream>
using namespace System;
using namespace std;
HANDLE hEvent;
DWORD WINAPI ChildThread(LPVOID iValue)
{
cout<<”Hello from the Child Thread”<<endl;
return 0;
}
int main()
{
HANDLE hCThread;
DWORD dwGenericThread;
hCThread = CreateThread(NULL,0,ChildThread,NULL,0,NULL);
cout<<"Waiting for the thread to complete.."<<endl;
WaitForSingleObject(hCThread,INFINITE);
cout<<"Thread Completed."<<endl ;
CloseHandle(hCThread);
return 0;
}
|