locked
What is the replacement of SetThreadPriority and GetThreadPriority for windows RT?

    Question

  • I am porting a windows desktop app to metro style app.

    My desktop app uses the following system API functions:

    SetThreadPriority

    GetThreadPriority

    Both the functions are declared in processthreadsapi.h for windows desktop app.These functions  are not compatible for metro style app.

    Is there any replacement of these functions for metro style app?
    Monday, September 3, 2012 12:16 PM

Answers

All replies

  • I am not aware of direct replacements for these, but I have not researched this to know for sure. generally the MSDN docs are complete regarding what is available for Windows 8 Store apps vs Desktop apps.

    What are you trying to achieve by changing the thread priority? perhaps this can be accomplished some other way.

    in general changing thread priority can be dangerous; impacting the behavior of the system in ways that are untested. it can also lead to priority inversion.

    Chris

    Monday, September 3, 2012 9:07 PM
  • Hello,

    There is WorkItemPriority in Windows::System::Treading, which you can use it create thread pool in Win8 Style app.

    Please check this document
    How to create a periodic work item
    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj248676.aspx
    And this Thread pool sample
    http://code.msdn.microsoft.com/windowsapps/Pool-Sample-5aa60454

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, September 4, 2012 8:48 AM
  • Hi  Jesse,

    I also have the same problem. I am porting my Desktop app to metro. As I would not like to use thread pool and want to use _beginthreadex instead for creating new worker thread, so i need the equivalent of SetThreadPriority/GetThreadPriority.



    Wednesday, September 5, 2012 1:04 PM
  • That API is not permitted. See this list:

    Windows Runtime Unsupported CRT Functions


    David Lamb

    • Proposed as answer by Jesse Jiang Thursday, September 6, 2012 5:46 AM
    • Marked as answer by Jesse Jiang Monday, September 24, 2012 8:50 AM
    Wednesday, September 5, 2012 3:07 PM
    Moderator
  • I am aware about  Windows::System::Threading.

    I am porting a current desktop app to metro style.If i go for WorkItemPriority in Windows::System::Threading i have to do a lot of modification in my existing code.If i go for  Windows::System::Threading ,i will surely miss my deadlines. 

    Thats why i am looking for the exact replacement of

    SetThreadPriority

    GetThreadPriority

    so that i can complete my project earlier.

    Friday, September 7, 2012 3:43 AM
  • Fahad,

    _beginthreadex is desktop family library and it is deprecated in Windows store apps.

    In Windows 8 Release Preview (build 8400), unfortunately _beginthreadex go out of #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP conditions. That's why you can use it. In  Windows 8 RTM this problem is resolved and _beginthreadex & its co are no longer available.

    So there is no chance to use SetThreadPriority/GetThreadPriority, you have to use threadpool  and WorkItemPriority instead it

    • Marked as answer by Jesse Jiang Monday, September 24, 2012 8:50 AM
    Monday, September 17, 2012 1:14 PM