Im tratando de cambiar la prioridad de subprocesos en el impulso, pero no tengo suerte. Recibo un error de manejo incorrecto (tipo 6) de la función GetLastError. ¿Pensé que native_handle() devolvió el identificador para el hilo?Cambiar la prioridad de subprocesos de subprocesos en Windows
¿Alguien sabe cómo hacer esto?
void baseThread::applyPriority(uint8 priority)
{
#ifdef WIN32
if (!m_pThread)
return;
BOOL res;
HANDLE th = m_pThread->native_handle();
switch (priority)
{
case REALTIME : res = SetPriorityClass(th, REALTIME_PRIORITY_CLASS); break;
case HIGH : res = SetPriorityClass(th, HIGH_PRIORITY_CLASS); break;
case ABOVE_NORMAL : res = SetPriorityClass(th, ABOVE_NORMAL_PRIORITY_CLASS); break;
case NORMAL : res = SetPriorityClass(th, NORMAL_PRIORITY_CLASS); break;
case BELOW_NORMAL : res = SetPriorityClass(th, BELOW_NORMAL_PRIORITY_CLASS); break;
case IDLE : res = SetPriorityClass(th, IDLE_PRIORITY_CLASS); break;
}
if (res == FALSE)
{
int err = GetLastError();
}
#endif
}
edición: código final:
void baseThread::applyPriority(uint8 priority)
{
#ifdef WIN32
if (!m_pThread)
return;
BOOL res;
HANDLE th = m_pThread->native_handle();
switch (priority)
{
case REALTIME : res = SetThreadPriority(th, THREAD_PRIORITY_TIME_CRITICAL); break;
case HIGH : res = SetThreadPriority(th, THREAD_PRIORITY_HIGHEST); break;
case ABOVE_NORMAL : res = SetThreadPriority(th, THREAD_PRIORITY_ABOVE_NORMAL); break;
case NORMAL : res = SetThreadPriority(th, THREAD_PRIORITY_NORMAL); break;
case BELOW_NORMAL : res = SetThreadPriority(th, THREAD_PRIORITY_BELOW_NORMAL); break;
case IDLE : res = SetThreadPriority(th, THREAD_PRIORITY_LOWEST); break;
}
#endif
}
que fue un error estúpido. Lo intentaré ahora. Gracias – Lodle