各位大虾,,如何在线程中调用线程外的函数,有没有这种可能或变通的方法,,多谢多谢
解决方案 »
- show的显示问题
- delphi adoquery的问题 怎么定位数据呢?
- 有关snmp的MIB浏览
- 在强烈郁闷中散分,入csdn以来首次散分
- 计算字段的合计问题,急!!!
- 初學delphi的兄弟姐妹們看過來.....,高手勿進!
- Title问题
- ClientDataset2:Cannot perform this operation on a closed dataset.
- access violation at address 1f9fd8f3 in module 'SQLSRV32.dll'.write of address 05461345
- 关于存储过程的问题
- Object Pascal 语法的一个问题??
- 我是新手,问一个简单的问题,谢谢
procedure Synchronize(Method: TThreadMethod);DescriptionSynchronize causes the call specified by Method to be executed using the main VCL thread, thereby avoiding multi-thread conflicts. If you are unsure whether a method call is thread-safe, call it from within the main VCL thread by passing it to the Synchronize method.Execution of the thread is suspended while Method is executing in the main VCL thread.Note: You can also protect unsafe methods using critical sections or the multi-read exclusive-write synchronizer.
var
lockxy:TCriticalSection; //lockxy必须是全局变量,以便对所有线程起作用。
... ...LockXY.Acquire; { 获取临界区}
try
Y := sin(X); //调用线程外函数
finally
LockXY.Release; //{交还临界区}
end;
解决办法如楼上所说...