the CatWalk example of thread control was written by Ron Thomas long times ago. it was a better example about thread control.
i translated it into x64 Uasm style. and added these "ExitThread,Ret "s function for a thread Exit.
pay attention to:
1. can't use ExitThread in your main thread, Use only own threads which will be exited.
2. monitoring the number of execution threads.
3. relate to I/O, DLL, MEMORY. "RET" is best. "ExitThread" is better. "TerminateThread" isn't good on unless necessary
res1
res2
Hi six_L
It works very well. Congrats :thumbsup:
Nice work!
Biterider
Works fine here. The sound is funny. :thumbsup:
Gunther
:thumbsup:
Find a little problem at rebuild.
Quote
;SendDlgItemMessageA PROTO hDlg:HWND ,nIDDlgItem:DWORD ,Msg:DWORD ,wParam:WPARAM ,lParam:LPARAM
WPARAM is a qword in X64 this made ThPriority1 (2) qword
hi: Biterider,Gunther,TouEnMasm
thank for your kind words and test.
especially,thank TouEnMasm for finding the error.
invoke SendDlgItemMessage, hdwnd, IDD_LB1, LB_GETCURSEL, 0,0
mov ThPriority1, rax
invoke SendDlgItemMessage, hdwnd, IDD_LB2, LB_GETCURSEL, 0,0
mov ThPriority2, rax
mov rax,ThPriority1
sub eax, HOFFSET
invoke SetThreadPriority, hThread1, eax
mov rax,ThPriority2
sub eax, HOFFSET
invoke SetThreadPriority, hThread2, eax
return TRUE
QuoteSetThreadPriority function (processthreadsapi.h)
Sets the priority value for the specified thread. This value, together with the priority class of the thread's process, determines the thread's base priority level.
Syntax
C++
BOOL SetThreadPriority(
HANDLE hThread,
int nPriority
);
Quote from: six_L on February 17, 2021, 05:47:37 AM
hi: Biterider,Gunther,TouEnMasm
thank for your kind words and test.
especially,thank TouEnMasm for finding the error.
you're welcome.
Good catch TouEnMasm. :thup:
Gunther
The SetThreadPriority parameters are a bit old.https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadpriority (https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadpriority)
I have changed those old parameters by the new in the upper link.
I have also added some various error messages.
bad parameters could be :
Quote
This value can be specified only if hThread is a handle to the current thread. The function fails
take care of that
hi,TouEnMasm
thank for you'd done on updating. :thumbsup:
There are more functions of thread control:
1. update to 9 levels priority;
2. add to the errors checking;
;----------------------------------------------
the deeper impression is used to translate between the list index and the priority index.