readingthread_unit.pas

来自「ah 209型通用读卡器驱动程序源码」· PAS 代码 · 共 59 行

PAS
59
字号
unit ReadingThread_Unit;

interface

uses
  Classes,Windows,SyncObjs;

type
  ReadingThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
  end;
var
  Card_No : integer;
  Card_Type : byte;
  b:boolean =false;
  ReadThread :ReadingThread;
  OnlyOwner  :TCriticalSection; //临界区
implementation

uses ReadCard, Unit2;

{ Important: Methods and properties of objects in VCL or CLX can only be used
  in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure ReadingThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ ReadingThread }

procedure ReadingThread.Execute;
begin
   while not terminated do
   begin
      SendCardComm(0);
      Sleep(100);
      Send_Card_Comm(Card_No,Card_Type,b);
      if((Card_No <> 0 ) and(Card_Type <>$00)) then
        begin
           OnlyOwner.Acquire;
           mCardNo:=Card_No;
           mCardType:=Card_Type;
           OnlyOwner.Release;
           sleep(5);
        end;

   end;
end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?