Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Delphi¶àÏß³Ìѧϰ£¨10£©£ºLabel(VCL)ͬ²½µÄÎÊÌâ

ÉÏÎÄÖУ¬¶àÏß³Ìͬ²½Ö÷´°ÌåµÄLabelµÄCaptionÊôÐÔÖµ£¬·¢ÏÖÒ»¸öÎÊÌ⣺ʹÓÃSynchronizeÓÃÓÚͬ²½µÄʱºò£¬Ö÷´°ÌåºÃÏñËÀµôÒ»Ñù£»¶øÖ±½ÓÓÃ×Ó³ÌÐòΪLabelµÄÒýÓø³Öµ£¬ÔòÓÐʱ»á³öÏÖ“Canvas  does not allow drawing”´íÎó¡£ÊéÉÏ˵VCLͬ²½Ò»¶¨ÒªÓÃSynchronize£¬¶ø²»ÄÜÖ±½Ó·ÃÎÊ¡£
    ²âÊÔ£º
{Ö÷´°Ìå}
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm2 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

uses TestThread;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
TTestThread.Create(Label1);
//TTestThread.Create(Label2);
//TTestThread.Create(Label3);
end;

end.{¶àÏß³ÌÀà}
unit TestThread;

interface

uses
Classes,StdCtrls;

type
TTestThread = class(TThread)
private
{ Private declarations }
FLabel:TLabel;
Fstr:string;
procedure UpdateLabel;
protected
procedure Execute; override;
public
constructor Create(Lab:TLabel);
end;

implementation

uses Unit2,SysUtils,windows;

{ TTestThread }

constructor TTestThread.Create(Lab: TLabel);
begin
FLabel:=Lab;
Inherited Create(False);
FreeOnTerminate:=True;
end;

procedure TTestThread.Execute;
var
i:Integer;
begin
{ Place thread code here }
for i := 0 to 20000 do
begin
if Not Terminated then
begin
Fstr:=Format('Ïß³ÌID£º%d,µÚ%d¸öÑ­»·',[GetCurrentThreadID,i]);
//UpdateLabel;
Synchronize(UpdateLabel);
end;
end;

end;

procedure TTestThread.UpdateLabel;
begin
FLabel.Caption:=Fstr;
end;

end.
¾­¹ý²âÊÔ£¬Ö»´´½¨Ò»¸öỊ̈߳¬ÓÃSynchronizeͬ²½Ö÷´°ÌåµÄÒ»¸öLabel£¬ÄÇô³ÌÐòÎÞÎÊÌ⣬¿ÉÒÔ¼ûµ½Í¬²½µÄ¹ý³Ì¡£µ±Í


Ïà¹ØÎĵµ£º

delphiʵÏÖÅúÁ¿¶ÁÈ¡¸ñʽÓйæÂɵÄÎı¾ÎļþµÄÄÚÈÝ.

ÏÖÓÐһϵͳ²»¶¨Ê±ÔÚͬһĿ¼ÏÂÉú³ÉÒ»ÅútxtÎļþ,ÄÚÈÝ´ó¸ÅÈçÏÂ;
      20100112_164910,6,81406392,808,113,,
Ϊ·½±ãͳ¼Æ,ÐèÒª½«ÕâЩtxtÎļþÖеÄÊý¾Ý¶ÁÈëÊý¾Ý±íÖÐ.
ÏÖÓÐÁ½ÖÖ·½·¨:
   Ò»ÊÇÖ±½Ó½«Êý¾Ý¶ÁÈëµ½Êý¾Ý±íÖеÄijһÁÐÖÐ,ÔÙÓÃsql Óï¾ä²ð¿ª³É¼¸ÁÐ: 
     ......

Delphi¶àÏß³Ìѧϰ£¨2£©£ºDelphiÖеĶàÏß³ÌÀàTThread¡£

2010-02-22 17:08:46
Delphi°Ñ¶àÏß³ÌÏà¹ØµÄAPI·â×°ÔÚTThreadÕâ¸öÀàÖУ¬¿ÉÒÔ·½±ãʵÏÖ¶àÏß³ÌÔËÓá£Ê×ÏÈ¿´ÏÂTThreadµÄÉùÃ÷£º
TThread = class

private
FHandle: THandle;
FThreadID: THandle;
FCreateSuspended: Boolean;
FTerminated: Boolean;
FSuspended: Boolean;
FFreeOnTerminate: ......

Delphi¶àÏß³Ìѧϰ£¨5£©£º»¥³âÁ¿Mutex

»¥³âÁ¿ÊÇϵͳÄں˶ÔÏó£¬Ë­ÓµÓоÍË­Ö´ÐС£ËüÓëÁÙ½çÇø¹¤×÷ºÜÀàËÆ¡£²»Í¬´¦ÔÚÓÚ£º1¡¢»¥³âÁ¿¿ÉÒÔ¿ç½ø³Ì±ß½çͬ²½Ï̡߳£2¡¢¿ÉÒÔ¸ø»¥³âÁ¿È¡¸öÃû×Ö£¬Í¨¹ýÒýÓû¥³âÁ¿µÄÃû×ÖÀ´Ê¹ÓÃÒ»¸öÒÑÖªµÄ»¥³âÁ¿¶ÔÏó¡£
     ʹÓû¥³âÁ¿Ö®ÀàµÄ¶ÔÏóÐèÒª·´¸´µ÷ÓÃϵͳÄںˣ¬ÆÚ¼äÐèÒª½øÐнø³ÌÉÏÏÂÎÄת»»ºÍ¿ØÖƼ¶±ðת»»£¬´ó¸ÅÐèÒªºÄ· ......

Delphi¶àÏß³Ìѧϰ(8)£ºÓÅÏȼ¶

Ò»¸öÏ̵߳ÄÓÅÏȼ¶È¡¾öÓÚ´´½¨Ï̵߳Ľø³ÌµÄÓÅÏȼ¶£¨priority class£©ºÍÏ̱߳¾ÉíÏà¶ÔµÄÓÅÏȼ¶£¨relative priority£©¡£
    1¡¢½ø³ÌÓÅÏȼ¶£º
    ²»Í¬²Ù×÷ϵͳ ÓÅÏȼ¶ÊýÄ¿²»Í¬¡£Windows2000ÒÔÉϵİ汾ÁбíÈçÏ£º
Idle£º£¨±êÖ¾£ºIDLE_PRIORITY_CLASS£¬ÖµÎª$40£©£»
Below Normal£º£¨±êÖ¾£ºBEL ......

Delphi¶àÏß³Ìѧϰ£¨9£©£º¶àÏß³ÌÊý¾Ý¿â²éѯ£¨ADO£©

ADO¶àÏß³ÌÊý¾Ý¿â²éѯͨ³£»á³öÏÖ3¸öÎÊÌ⣺
1¡¢CoInitialize ûÓе÷Óã¨CoInitialize was not called£©£»ËùÒÔ£¬ÔÚʹÓÃÈκÎdbGo¶ÔÏóÇ°£¬±ØÐëÊÖ µ÷ÓÃCoInitializeºÍCoUninitialize¡£µ÷ÓÃCoInitializeʧ°Ü»á²úÉú"CoInitialize was not called"ÀýÍâ¡£
2¡¢»­²¼²»ÔÊÐí»æ»­£¨Canvas does not allow drawing£©£»ËùÒÔ£¬±ØÐëͨ¹ýSynch ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ