LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the priority of MS windows tasks

Hallo! I was suggested to set the priority of my program with success=SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
But I don't know the basis!!! Do I have to put this line in Labwindows/CVI? Do I have to include anything? I'm not an expert programmer, please help me!
0 Kudos
Message 1 of 2
(3,324 Views)
Hello

Generally it's not a good idea to change the priority of your application, in case it hangs and your entire system starts to lock up. If this is just to make your application more responsive, try taking out time consuming tasks out of the UI thread and distribute the busy work to other threads so that the UI does not have to wait.
With all that said, you use this function, add windows.h as the very first include in your list of includes. And then call this function in main early on before you actually do major work:

#include
#include
.
.

static int panelHandle;

int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
SetPriorityClass(GetC
urrentProcess(),HIGH_PRIORITY_CLASS);

if ((panelHandle = LoadPanel (0, "test.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}

You can verify that the task priority change by using the task manager.

Hope this helps

Bilal Durrani
NI
Hope this helps
Bilal Durrani
NI
Message 2 of 2
(3,324 Views)