Ooops
October 29, 2020, 01:50:02 AM

Author Topic: [bb] Set Task-Application Priority by Barton [ 1+ years ago ]  (Read 1214 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Set Task-Application Priority
Author : Barton
Posted : 1+ years ago

Description : Here my SetPriority userlib for set the Task Priority. It is very good if running many other applications in the background during playing your game. Your Game or Application running then better without freezes. :)

Code :
Code: BlitzBasic
  1. Here my SetPriority userlib for set the Task Priority. It is very good if running many other applications in the background during playing your game. Your Game or Application running then better without freezes. :)
  2.  
  3. ==============
  4. SetPriority.decls
  5. ==============
  6.  
  7. .lib "kernel32.dll"
  8.  
  9. GetCurrentProcess%()  :"GetCurrentProcess"
  10. GetCurrentThread%()   :"GetCurrentThread"
  11. GetPriorityClass%()      :"GetPriorityClass"
  12. GetThreadPriority%()     :"GetThreadPriority"
  13. SetPriorityClass%(Process%, Value%)   :"SetPriorityClass"
  14. SetThreadPriority%(Process%, Value%):"SetThreadPriority"
  15.  
  16.  
  17.  
  18. =========
  19. example:
  20. =========
  21.  
  22. ;// THREAD
  23. Const THREAD_BASE_PRIORITY_IDLE = -15
  24. Const THREAD_BASE_PRIORITY_LOWRT = 15
  25. Const THREAD_BASE_PRIORITY_MIN = -2
  26. Const THREAD_BASE_PRIORITY_MAX = 2
  27. Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
  28. Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
  29. Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
  30. Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
  31. Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
  32. Const THREAD_PRIORITY_NORMAL = 0
  33. Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
  34. ;// CLASS
  35. Const REALTIME_PRIORITY_CLASS = 256
  36. Const HIGH_PRIORITY_CLASS = 128
  37. Const IDLE_PRIORITY_CLASS = 64
  38. Const NORMAL_PRIORITY_CLASS = 32
  39.  
  40. hThread%  = GetCurrentThread()
  41. hProcess% = GetCurrentProcess()
  42. SetThreadPriority hThread%, THREAD_PRIORITY_LOWEST  ;<< SET YOUR THREAD PRIORITY HERE!!
  43. SetPriorityClass  hProcess%, IDLE_PRIORITY_CLASS ;<< SET YOUR PRIORITY CLASS HERE!!
  44.  
  45.  
  46.  
  47. You can check it when you start your task manager and right click the mouse button over your app-name.exe in the list.


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal