Thread: SetThreadPriority

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    20

    SetThreadPriority

    I have spent a few days on this already...

    I am using _beginthread and _endthread, but I cannot correctly set the priority.

    !!!Does someone have a simple example of how to use SetThreadPriority???

    Currently I am trying to check if the function fails and it always does so I get extended error information, by calling GetLastError.

    The hard part is an arg needs to be handle to the thread. But the thread I run are of type void __cdecl. Even after recasting it the SetThreadPriority fails with GetLastError returning "inappropriate handle".

    Thank you!

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Doesn't beginthread return the handle you should use for SetThreadPriority?
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    20
    FYI: This code is being developed in MS Visual C++ 6.0.

    I use the function with a void argument and void return. According to MSDN the function uses __cdecl calling convention and should have no return value.

    Code:
    uintptr_t _beginthread( 
       void( __cdecl *start_address )( void * ),
       unsigned stack_size,
       void *arglist 
    );

Popular pages Recent additions subscribe to a feed