Home > Back-end > A let I don't know how to describe the multi-thread problem
A let I don't know how to describe the multi-thread problem
Time:10-02
//thread class the following Type Tusercj=class (TThread) User: string; Pass: a string; Name: string;//the nickname Date_str: string;//acquisition date Date_t: tDate;//acquisition date Date_curr: TDate;//date collection and the current date now Get_day: Integer;//need to collect the number of days Htmlcode: string; STR: string; Error_count: Integer;//error statistics TAB: TTabSheet; Memo: TmxMemo;//log dialog Param: TStringList;//POST submission parameter Idssl: TIdSSLIOHandlerSocket;//SSL need Idhttp: TIdHTTP;//POST to get the data controls Vercode: TMemoryStream;//verification code file bytes Qry qry1, qry2: TADOQuery; Protected Procedure the Execute; Override.//thread and make Procedure the main ();//acquisition main function Procedure data_count ();//data statistics Procedure save_xml ();//generate XML Procedure log (STR: string);//log The function get_data () : Integer;//get data specified date The function check_error () : a Boolean;//check whether achieve maximum error The function selectuser () : a Boolean;//check if the date data exist The function get_vercode () : string;//to get verification code The end;
The Execute; With the Create TAB and M TAB:=TTabSheet. Create (Form1. Pgc1); TAB. Caption:=the self. The user; TAB. Parent:=Form1. Pgc1; TAB. PageControl:=Form1. Pgc1; TAB. The Align:=alClient; Memo:=tmxmemo. Create (TAB); Memo. Parent:=TAB; Memo. The Align:=alClient;
Problem is to create the MEMO does not receive any news and events, such as the above write a MEMO to normal display. But add a MEMO on lines. The add (" text "); MEMO field on your form is showed not to come out, use sendmessage sending messages to also do not accept, but if you are creating manual MEMO opens at the form, after reoccupy sendmessage sending messages, and can receive,
Question is why MEMO will not display properly
CodePudding user response:
This is a thread safety, Should not be created in the thread and access interface element,
Suggestion: after the data is ready, through SendeMessage message to main form, tell the main form has been processed, the main form can hang up the thread (see your needs), structural interface elements and reads the data thread class prepared...
CodePudding user response:
Thank you moderator's adult, but I now the question is, memo is thread execution logs to reality, you can see there is a LOG process, is it sendmessage send used to create a memo data, processed to build is certainly not