¹ØÓÚ Delphi TThread
TThreadÊÇÒ»¸ö³éÏóÀà,ÓÃÓÚÔÚdelphiÖд´½¨Ï̡߳£
´´½¨Ò»¸öTThreadµÄ×ÓÀà¶ÔÏó¼´Ï൱ÓÚ´´½¨Ò»¸öÏ̡߳£¡¡¡¡
µ±Ò»¸öÓ¦ÓóÌÐòÔËÐÐʱ£¬Ó¦ÓóÌÐò¾Í±»ÔØÈëÄÚ´æ×¼±¸Ö´ÐС£´Ëʱ£¬Ëü³ÉΪ°üº¬Ò»¸ö»ò¶à¸öÏ̵߳Ľø³Ì¡£Ïß³ÌÖ´ÐÐÓ¦ÓóÌÐòµÄ²¿·ÖÄÚÈÝ£¬²¢ÓɲÙ×÷ϵͳ·ÖÅäCPUʱ¼ä¡£Í¬Ò»½ø³ÌµÄËùÓÐÏ̹߳²ÏíͬһµØÖ·¿Õ¼ä£¬¿ÉÒÔ·ÃÎʽø³ÌµÄÈ«¾Ö±äÁ¿¡£
Ïß³Ìͨ¹ýÒÔϹ¤×÷¸ÄÉÆÓ¦ÓõÄÐÔÄÜ£º
¹ÜÀí¶àͨÐÅÉ豸µÄÊäÈë¡£
¡¡¡¡ Çø·ÖÈÎÎñµÄÓÅÏȼ¶¡£ÓÅÏȼ¶¸ßµÄ´¦Àí½ô¼±µÄÈÎÎñ¡£ÓÅÏȼ¶µÍµÄ´¦ÀíÆäËûÈÎÎñ¡£
ÒÔÏÂÊÇʹÓÃÏ̵߳ÄһЩ½¨Ò飺
¡¡¡¡ ͬʱ¸ú×ÙÌ«¶àµÄÏß³ÌÏûºÄCPUʱ¼ä¡£¶Ôµ¥´¦ÀíÆ÷ϵͳ£¬Ò»¸ö½ø³Ì×î¶àÓÐ16¸öÏ̡߳£
¡¡¡¡ µ±¶à¸öÏ̸߳üÐÂÏàͬµÄ×ÊԴʱ£¬Ó¦Ê¹Ïß³Ìͬ²½ÒÔ±ÜÃâ³åÍ»¡£
¡¡¡¡ ´ó¶àÊý·ÃÎÊVCL¶ÔÏóºÍ¸üд°ÌåµÄ·½·¨±ØÐë´ÓÖ÷Ïß³ÌÄÚ²¿µ÷Óá£
¡¡¡¡ ÒÔÏÂΪ´´½¨ºÍʹÓÃÒ»¸öÐÂÏ̵߳Ĺý³Ì£º
¡¡¡¡ £¨1£©µ¥»÷File|New|Thread²Ëµ¥Ï´´½¨Ò»¸öTThreadµÄ×ÓÀà¡£
¡¡¡¡ £¨2£©¶¨ÒåCreate·½·¨¡£
¡¡¡¡ £¨3£©Í¨¹ý²åÈëÏß³ÌÖ´ÐÐʱÐèÒªµÄ´úÂ붨ÒåExecute·½·¨¡£
¡¡¡¡ £¨4£©½«Ê¹ÓÃVCL×é¼þµÄÈκε÷Óô«µÝ¸øSynchronize·½·¨£¬ÒÔ±ÜÃâ¶àÏ̳߳åÍ»¡£
ÊôÐÔÁбí
FreeOnTerminate Ïß³ÌÖÕֹʱ¸Ã¶ÔÏóÊÇ·ñ×Ô¶¯É¾³ý
Handle Ï߳̾ä±ú
Priority È·¶¨¸ÃÏß³ÌÏà¶ÔÓÚ½ø³ÌÖÐÆäËûÏ̵߳ÄÓÅÏȼ¶
ReturnValue ·µ»ØÏß³ÌÖµ
Suspended ָʾһÏß³ÌÊÇ·ñ±»¹ÒÆð
Terminated ±íÃ÷Ï̱߳»ÒªÇóÖÕÖ¹
ThreadID Identifies the thread throughout the system.
·½·¨Áбí
~TThread ɾ³ýÏ̶߳ÔÏó²¢ÊÍ·ÅÆäÕ½ÓõÄÄÚ´æ¿Õ¼ä
DoTerminate ²úÉúÒ»¸öOnTerminateʼþ
Execute Ìṩ°üº¬Ïß³ÌÖ´ÐÐʱËùÐè´úÂëµÄ³éÏó·½·¨
Resume ÖØÐÂÖ´ÐÐÒ»¸ö¹ÒÆðµÄÏß³Ì
Suspend ¹ÒÆðÒ»¸öÔËÐÐÖеÄÏß³Ì
Synchronize ÔÚÖ÷VCLÏß³ÌÖÐÖ´ÐÐMethod
Terminate ½«TernimatedÊôÐÔÉèÖÃΪTrue֪ͨÏß³ÌÖÕÖ¹
TThread ´´½¨Ò»¸öÏ̶߳ÔÏóµÄʵÀý
WaitFor µÈ´ýÏß³ÌÖÕÖ¹²¢·µ»ØReturnValueÊôÐÔÖµ
ʼþÁбí
OnTerminate Execute ·½·¨ÒÑ·µ»ØÇÒ¸ÃÏ̱߳»É¾³ýÇ°·¢Éú
ÊôÐÔ
TThread::FreeOnTerminate
__property bool FreeOnTerminate = {read=FFreeOnTerminate,write=FFreeOnTerminate,nodefault};
È·¶¨µ±Ïß³ÌÖÕֹʱ£¬¸ÃÏ̶߳ÔÏóÊÇ·ñ×Ô¶¯É¾³ý¡£
FreeOnTerminateĬÈÏֵΪFalse£¬Ï̶߳ÔÏó±ØÐëÔÚ´úÂëÖÐÏÔʾɾ³ý¡£
TThread::Handle°üº¬Ï߳̾ä±ú¡£µ±µ÷ÓÃWin32APIº¯Êý´¦ÀíÏß³Ìʱ£¬Ê¹ÓÃHandle.
Thread::Priority
_
Ïà¹ØÎĵµ£º
15±¾DelphiÊé¼®(PDF¸ñʽ)ÏÂÔØ (ת)
ÎļþÃû: Delphi×é¼þ²Î¿¼´óÈ«.rar
ÏÂÔصØÖ·: http://www.rayfile.com/files/678ca1e3-f73f-11de-9d02-0014221b798a/
ÎļþÃû: DelphiÐÅϢϵͳ¿ª·¢ÊµÀý¾«Ñ¡.rar
ÏÂÔصØÖ·: http://www.rayfile.com/files/fb328f02-f73e-11de-8a76-0014221b798a/
ÎļþÃû ......
¼¼Êõ½»Á÷,DH½²½â. ¹þ¹þ,ÎÒ³ÐÈÏÎÒÊDZêÌâµ³.
×î½ü¿´ÌìÊéÒ¹¶ÁÀïÃæÊǶÔCÓïÑԵĴúÂë·´»ã±à,²»´í,¿ÉϧDelphiûÓÐÕâÑùµÄÊé,ÄÇÎÒÃÇ×Ô¼º¶¯ÊÖ°É.
Ê×ÏȽøÈëForÑ»·ÁË. Function TestFor( a, b: Integer ): Integer ;
Var
I: Integer ;
Begin
Result := a + b ;
For I := 0 To 49 Do
Result := Result + I ......
ÏûÏ¢µÄ´¦ÀíÁ÷³Ì£¬Á÷³ÌÈçÏ£º
ÆäÅÉ·¢´¦Àí¹ý³ÌÏêϸÈçÏ£º
×¢Ò⣺TWinControlÀïÃæWndProcÓе÷ÓÃϵͳAPI DefWindowProc,¸Ãº¯Êýµ÷ÓÃȱʡµÄ´°¿Ú¹ý³ÌÀ´ÎªÓ¦ÓóÌÐòûÓд¦ÀíµÄÈκδ°¿ÚÏûÏ¢ÌṩȱʡµÄ´¦Àí¡£¶øTWinControlÀïÃæDefaultHandlerÓÖµ÷ÓÃÁËϵͳAPI CallWindowProc£¬¸Ãº¯ÊýCallWindowProc½«ÏûÏ¢ÐÅÏ¢´«Ë͸øÖ¸¶¨µÄ´°¿ ......
ÈçºÎµ÷ÊÔDLL£¬ÔÚÕâÀï¾Í²»ÔÙ׸ÊöÁË£¬µ«ÊÇ£¬½ñÌì¾ÍÅöµ½ÁËÒ»¸öÌرðÆæ¹ÖµÄÎÊÌ⣬²ÎÊýÉèÖÃÕýÈ·£¬¾ÍÊDz»Äܵ÷ÊÔ£¿£¿ ͨ¹ýÉÏÍø²é×ÊÁÏ£¬·¢ÏÖÁËÎÊÌ⣬עÒ⣺
1£¬ ½«ProjectÖ÷²Ëµ¥µÄProject Options¶Ô»°¿òµÄCompilerÒ³ÃæDebuggingÑ¡ÏîÖÐµÄ Debug informaton¡¢Local symbols¡¢Assertions¸´Ñ¡¿òÑ¡ÖÐ
2£¬½«ToolsÖ÷²Ëµ¥µÄD ......
Ö¸ÕëÓ÷¨µÄÀý×Ó£º
1 var
2 X, Y: Integer; // X and Y ÕûÊýÀàÐÍ
3 &n ......