通讯问题(50)

O

ortega

Unregistered / Unconfirmed
GUEST, unregistred user!
我写了这样一个过程 FillResult(AIndex: integer; AData: String);procedure FrmMain.FillResult(AIndex: integer; AData: String);begin .... TMemo(FindComponent('Mem' + IntToStr(AIndex))).Lines.add(AData); ....end;有多个ServerSocket: TServerSocket; 在ServerSocket的OnClientRead事件里面调用FillResult(), 同时调用会有问题吗,用线程怎么解决
 
怕出问题,用CriticalSection保护一下了。Delphi封装好了TRTLCriticalSection,很方便。
 
楼上是指用多线程的临界区? 详细点
 
在多线程中访问VCL组件必须做好线程安全访问建议用消息处理比较好。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 adfae.UpdateCaption; begin Form1.Caption := 'Updated in a thread'; end;
 
好好学学线程是怎么回事,自己写,别人给你写,你也不明白道理。
 
顶部