The function ReadEmpNo (Port, BaudRate: Integer; EmpNo: an array of byte) : Integer; Stdcall; External 'Reader. DLL';
Type
TMyThread=class (TThread)
Protected
Procedure the Execute; Override.
end;
Procedure TMyThread. Execute;
Var
I: Integer;
EmpNo: array [0.. 10] of byte;
StrNo: string;
The begin
FreeOnTerminate:=True; {this allows threads execute immediately after the release}
Try
//while (true) do
The begin
StrNo:=';
If ReadEmpNo (StrToInt (' 1 ') - 1, 19200, EmpNo)=0 then
The begin
//ShowMessage (Trim (PChar (@ EmpNo)));
StrNo:=Trim (PChar (@ EmpNo));
end;
FormC_input. Edt_no. Text:='22222';//strNo;
Sleep (3000);
end;
The finally
//variable. Free;
end;
end;
Problem is in the red part, it is this FORM of unable to get value up. The control.
But the code I wrote another with D7. A program can be out.
CodePudding user response:
Is the line 26Color can't
FormC_input. Edt_no. Text:='22222';//strNo;
CodePudding user response:
Threads do not modify the VCL, directly Delphi VCL is not secure multithreaded,Add a procedure to Form, and then using the Synchronize threads synchronization to the main thread of execution, in this procedure, modify the value of the VCL
CodePudding user response:
Agree with upstairs, as long as to allow access to the UI, you need to use synchronization function