|
|
1.1 root 1: Sample: Using Thread API Functions
2: Summary:
3:
4: The THREADS sample application shows how to use
5: SetThreadPriority, SuspendThread, and ResumeThread.
6:
7: More Information:
8:
9: To use THREAD, start the application. Two threads will be
10: created; one will draw a red rectangle and the other a green
11: rectangle. Both of these rectangles move about the window;
12: their speed and behavior is based on the thread priority and
13: its resumed/suspended status. The priority and status are
14: set through menu selections.
15:
16: Of special interest is the suspension count. The system
17: keeps track of the number of times a thread has been
18: suspended and resumed. Each time the thread is suspended,
19: the count is incremented; each time it is resumed, the count
20: is decremented. The suspension count can either be tracked
21: by applications manually, the same way this sample
22: application does, or the return value from ResumeThread and
23: SuspendThread can be used to obtain the previous suspension
24: count before the call was made. Only when the suspension
25: count is zero will the thread run.
26:
27: A thread has only five priorities that you are allowed to
28: use:
29:
30: THREAD_PRIORITY_LOWEST
31: THREAD_PRIORITY_BELOW_NORMAL
32: THREAD_PRIORITY_NORMAL
33: THREAD_PRIORITY_ABOVE_NORMAL
34: THREAD_PRIORITY_HIGHEST
35:
36: Other priorities are reserved for use by the system only.
37:
38: The following is a list of the Win32 API functions used in
39: this sample:
40:
41: CreateSolidBr GetMessage Rectangle Sleep
42: ush
43: CreateThread GetStockObjec RegisterClass SuspendThread
44: t
45: CreateWindow GetSystemTime ReleaseDC TerminateThre
46: ad
47: DispatchMessa LoadCursor ResumeThread wsprintf
48: ge
49: GetClientRect LoadIcon SelectObject
50: GetDC MessageBox SetThreadPrio
51: rity
52: GetLastError PostQuitMessa ShowWindow
53: ge
54:
55:
56:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.