Wednesday, 31 March 2010

Waiting for Thread / Process termination

When launching child processes from applications I used to use GetExitCodeProcess on the process handle, checking if STILL_ACTIVE is returned if it is still running.. heres the smart way!

After spawning a process or creating a worker thread the end of the process/thread can be waited on using WaitForSingleObject.

For instance for threads:

HANDLE hThread;
hThread = CreateThread(NULL,0,StartThread,&threadParam,0,NULL);
if(hThread1 != NULL)

For processes:

if (CreateProcess (parameters, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, &pi))

Thursday, 25 March 2010

Registry notifications to pass data between kernel to Apps/drivers

This breifly outlines the technique of passing information or state changes between the Windows CE Kernel/OAL and running drivers or applications. Passing events and notification from the kernel to a driver or application can be a little problematic, information flow the other way is straight forward using the kernel IOCtls.

One thing we can use here is the registry and the registry change notifications, for instance, both drivers/applications and kernel can change the registry, the kernel calls are all preceeded by NK, for instance:





So why not set a state or value to pass in the registry, then wait on a particular registry key or value being changed using the following:

// create an event on a particular registry change
HANDLE event = CeFindFirstRegChange(....)

// wait for notification of a change
WaitForSingleObject(event, INFINITE);

// clear event


Using this technique small, or large complex data can be shared very easily.

Thursday, 11 March 2010

Platform Builder: Remember to enable Multiprocessor Build

A support incident today reminded me that many people have forgotten to enable Multiprocessor Build support.

Enabling this will reduce the overall time it takes to build a platform workspace and it can be autodetected if enabled. But it seems the default is a manual selected number of processors=1

The selection is accessed via Tools / Options with the selection options as captured below:

Hope this is of help. Nigel

Thursday, 4 March 2010

Passing data using SetEvent on Windows CE

Martin in the office came across this one, normally SetEvent is used to signal between two threads or even processes that something has happened, a very light weight message queue shall we say, the major limitation is that you can't pass any parameters or data, so you end up having multiple events or storing the parameter information in the registry etc..but using this API you can associate a DWORD of information against an event that is signalled, pretty handy for simple signalling information between drivers and applications...

BOOL SetEventData(   HANDLE hEvent,   DWORD dwData );
For more information look at: