initial commit
[rofl0r-KOL.git] / main_tthread.htm
blob8e151a3a6b5ac8998a9967ca2332e484284b9df8
1 <html>
2 <head>
3 <title>KOL Help: TThread object (main frame)</title>
4 <base target="_top">
5 </head>
7 <body bgcolor="#FFFFEF" text="#000000" link="#008080" vlink="#008000" alink="#808000">
8 <p><font face="Courier" color="#800080"><b>TThread( unit <a href=kol_pas.htm>KOL.pas</a> )
9 <font face="Wingdings">ï</font> <a href=tobj.htm>TObj</a>
10 <font face="Wingdings">ï</font> <a href=_tobj.htm>_TObj</a>
11 </b></font></p>
12 <p><b>
13 TThread = object( <a href=tobj.htm target="_top">TObj</a> )
14 </b></p>
15 Thread object. It is possible not to derive Your own thread-based
16 object, but instead create thread <a href=#suspended target="main">Suspended</a> and assign event
17 <a href=#onexecute target="main">OnExecute</a>. To create, use one of <a href=kol_pas.htm#newthread target="_top">NewThread</a> of <a href=kol_pas.htm#newthreadex target="_top">NewThreadEx</a> functions,
18 or derive Your own descendant object and write creation function
19 (or constructor) for it.
20 <br><br>
21 Aknowledgements. Originally class ZThread was developed for XCL:
22 <br> * By: Tim Slusher : junior@nlcomm.com
23 <br> * Home: http://www.nlcomm.com/~junior
24 <h3 align="center"><font color="#FF8080">TThread properties</font></h3>
25 <a name="handle"></a>
26 <p>
27 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Handle</b></font>: THandle;</font>
28 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
29 <br>
30 Thread handle. It is created immediately when object is created
31 (using <a href=kol_pas.htm#newthread target="_top">NewThread</a>).
32 </p>
33 <a name="suspended"></a>
34 <p>
35 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Suspended</b></font>: <b>boolean</b>;</font>
36 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
37 <br>
38 True, if suspended.
39 </p>
40 <a name="terminated"></a>
41 <p>
42 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Terminated</b></font>: <b>boolean</b>;</font>
43 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
44 <br>
45 True, if terminated.
46 </p>
47 <a name="threadid"></a>
48 <p>
49 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>ThreadId</b></font>: <b>DWORD</b>;</font>
50 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
51 <br>
52 Thread id.
53 </p>
54 <a name="priorityclass"></a>
55 <p>
56 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>PriorityClass</b></font>: <b>Integer</b>;</font>
57 <br>
58 Thread priority class. One of following values: HIGH_PRIORITY_CLASS,
59 IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS.
60 </p>
61 <a name="threadpriority"></a>
62 <p>
63 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>ThreadPriority</b></font>: <b>Integer</b>;</font>
64 <br>
65 Thread priority value. One of following values: THREAD_PRIORITY_ABOVE_NORMAL,
66 THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_IDLE,
67 THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_NORMAL, THREAD_PRIORITY_TIME_CRITICAL.
68 </p>
69 <a name="data"></a>
70 <p>
71 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Data</b></font>: <b>Pointer</b>;</font>
72 <br>
73 Custom data pointer. Use it for Youe own purpose.
74 </p>
75 <a name="autofree"></a>
76 <p>
77 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>AutoFree</b></font>: <b>Boolean</b>;</font>
78 <br>
79 Set this property to true to provide automatic destroying of thread
80 object when its executing is finished.
81 </p>
82 <h4 align="center"><font color="black">Properties, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
83 <h3 align="center"><font color="#FF8080">TThread methods</font></h3>
84 <a name="destroy"></a>
85 <p>
86 <font face="Courier" color="#800080"><b>destructor</b> <font color="#808000"><b>Destroy</b></font>; <b>virtual</b>;</font>
87 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#78;</font>&nbsp;&nbsp;&nbsp;
88 <br>
89 </p>
90 <a name="execute"></a>
91 <p>
92 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>Execute</b></font>: <b>integer</b>; <b>virtual</b>;</font>
93 <br>
94 Executes thread. Do not call this method from another thread! (Even do
95 not call this method at all!) Instead, use <a href=#resume target="main">Resume</a>.
96 <br>
97 Note also that in contrast to VCL, it is not necessary to create your
98 own descendant object from TThread and override Execute method. In KOL,
99 it is sufficient to create an instance of TThread object (see <a href=kol_pas.htm#newthread target="_top">NewThread</a>,
100 <a href=kol_pas.htm#newthreadex target="_top">NewThreadEx</a>, <a href=kol_pas.htm#newthreadautofree target="_top">NewThreadAutoFree</a> functions) and assign <a href=#onexecute target="main">OnExecute</a> event
101 handler for it.
102 </p>
103 <a name="resume"></a>
105 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Resume</b></font>;</font>
106 <br>
107 Continues executing. It is necessary to make call for every
108 nested <a href=#suspend target="main">Suspend</a>.
109 </p>
110 <a name="suspend"></a>
112 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Suspend</b></font>;</font>
113 <br>
114 Suspends thread until it will be resumed. Can be called from another
115 thread or from the thread itself.
116 </p>
117 <a name="terminate"></a>
119 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Terminate</b></font>;</font>
120 <br>
121 Terminates thread.
122 </p>
123 <a name="waitfor"></a>
125 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WaitFor</b></font>: <b>Integer</b>;</font>
126 <br>
127 Waits (infinitively) until thead will be finished.
128 </p>
129 <a name="synchronize"></a>
131 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Synchronize</b></font>( Method: TThreadMethod );</font>
132 <br>
133 Call it to execute given method in main thread context. <a href=kol_pas.htm#applet target="_top">Applet</a> variable
134 must exist for that time.
135 </p>
136 <a name="synchronizeex"></a>
138 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>SynchronizeEx</b></font>( Method: TThreadMethodEx; Param: <b>Pointer</b> );</font>
139 <br>
140 Call it to execute given method in main thread context, with a given
141 parameter. <a href=kol_pas.htm#applet target="_top">Applet</a> variable must exist for that time. Param must not be nil.
142 </p>
143 <h4 align="center"><font color="black">Methods, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
144 <h3 align="center"><font color="#FF8080">TThread events</font></h3>
145 <a name="onexecute"></a>
147 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>OnExecute</b></font>: <a href=kol_pas.htm#tonthreadexecute target="_top">TOnThreadExecute</a>;</font>
148 <br>
149 Is called, when <a href=#execute target="main">Execute</a> is starting.
150 </p>
151 <a name="onsuspend"></a>
153 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>OnSuspend</b></font>: <a href=kol_pas.htm#tobjectmethod target="_top">TObjectMethod</a>;</font>
154 <br>
155 Is called, when <a href=#suspend target="main">Suspend</a> is performed.
156 </p>
157 <a name="onresume"></a>
159 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>OnResume</b></font>: <a href=kol_pas.htm#tonevent target="_top">TOnEvent</a>;</font>
160 <br>
161 Is called, when resumed.
162 </p>
163 <h4 align="center"><font color="black">Events, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
164 <h3 align="center"><font color="#FF8080">TThread fields</font></h3>
165 <h4 align="center"><font color="black">Fields, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
166 <hr>
167 <p align="center">[&nbsp;<a href=index.htm>Index</a>&nbsp;]</p>
168 <p align="center"><font face="Comic Sans MS"><small>This help is generated 22-Sep-2005 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov<br>Modified (C) 2003 by Alexander Bartov</small></font></p>
169 </body>
170 </html>