El manejador de un Thread

26/02/2004 - 12:47 por vIndEx | Informe spam
Hola. Esto es un poco farragoso de contar, pero intentaré ser lo más claro
posible. Estoy desarrollando una aplicacion en Windows CE con compact
framework.
La aplicación tiene que ser multihilo, y cada hilo tiene que tener su propia
prioridad. La clase System.Threading.Thread tiene una propiedad llamada
Priority donde se puede cambiar la prioridad, pero el problema es el
siguiente: al parecer Windows XP sólo soporta 5 niveles de prioridad
(Windows CE soporta 256), así que
sólo puedo darle esos 5 valores a la propiedad.

Así, la alternativa es llamar a la API de Windows CE, y resulta que para lo
que quiero existen estas dos funciones:

BOOL CeSetThreadPriority(HANDLE hThread, int nPriority);

int CeGetThreadPriority(HANDLE hThread);

Pues aquí es donde llega mi problema: no se como sacar el manejador (handle)
del thread que creo con System.Threading.Thread. Y me hace falta para
pasárselo a estas dos funciones.

Gracias por la ayuda.
 

Leer las respuestas

#1 vIndEx
27/02/2004 - 13:12 | Informe spam
Si, ya habia visto esto, pero la verdad es que no tengo ni idea de lo que
tengo que pasarle a esos parametros, sobre todo al lpStartAddress, que se
supone
que es un puntero al método que quiero ejecutar. ¿Tendre que pasarle un
delegado o algo parecido?


"Camilo Villa" wrote in message
news:OcgqjiO$
Tienes que crear un Thread, pero de Windows CE.

he aqui como lo creas

To create a thread, call the CreateThread function. The following code
example shows the CreateThread function prototype.

HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );Because
Windows CE does not support the lpThreadAttributes and dwStackSize
parameters, you must set them to NULL or 0. The following table describes
the remaining CreateThread parameters.

Parameter Description
lpStartAddress Points to the start of the thread routine.
lpParameter Specifies an application-defined value that is passed to
the thread routine.
dwCreationFlags Set to 0 or CREATE_SUSPENDED and/or
STACK_SIZE_PARAM_IS_A_RESERVATION.
lpThreadId Points to a DWORD that receives the new thread's
identifier.

If CreateThread is successful, it returns the handle to the new thread and
the thread identifier. You can also retrieve the thread identifier by
calling the GetCurrentThreadId function from within the thread. In Windows
CE, the value returned in GetCurrentThreadId is the actual thread handle.
You can also retrieve a handle to the thread by calling the


GetCurrentThread
function. This function returns a pseudo-handle to the thread that is


valid
only while in the thread. If you specify CREATE_SUSPENDED in the
dwCreationFlags parameter, the thread is created in a suspended state and
must be resumed with a call to the ResumeThread function.

You can terminate a thread by calling ExitThread, which frees the


resources
that are used by a thread when they are no longer needed. Calling


ExitThread
for an application's primary thread causes the application to terminate.

Espero esto despeje más tus dudas... seguiré buscando a ver que más


encuento
relevante a este tema
Camilo Alfonso Villa N.
APTECH Certified Visual Studio .NET
Microsoft 3 DCE

"vIndEx" escribió en el mensaje
news:euXu94F$
> Hola. Esto es un poco farragoso de contar, pero intentaré ser lo más


claro
> posible. Estoy desarrollando una aplicacion en Windows CE con compact
> framework.
> La aplicación tiene que ser multihilo, y cada hilo tiene que tener su
propia
> prioridad. La clase System.Threading.Thread tiene una propiedad llamada
> Priority donde se puede cambiar la prioridad, pero el problema es el
> siguiente: al parecer Windows XP sólo soporta 5 niveles de prioridad
> (Windows CE soporta 256), así que
> sólo puedo darle esos 5 valores a la propiedad.
>
> Así, la alternativa es llamar a la API de Windows CE, y resulta que para
lo
> que quiero existen estas dos funciones:
>
> BOOL CeSetThreadPriority(HANDLE hThread, int nPriority);
>
> int CeGetThreadPriority(HANDLE hThread);
>
> Pues aquí es donde llega mi problema: no se como sacar el manejador
(handle)
> del thread que creo con System.Threading.Thread. Y me hace falta para
> pasárselo a estas dos funciones.
>
> Gracias por la ayuda.
>
>




Preguntas similares