Crash when setting priority of a thread

If i try to set a thread’s priority with


it crashes with error

Error Status: 0x80010132 Code: 306 Module: 1
Error Message: Thread: 0x0, Parameter error

Do i need to do anything else before setting priority?

Has the thread been started yet? It looks like it may need to be running before you can call this.