可这样做:
1。窗体类中:
const
WM_REFRESH_DATA = WM_USER + 1;
type
TMainForm = class(TForm)
...
private
procedure WmRefreshData(var Message: TMessage);
message WM_REFRESH_DATA;
public
FDeltaVar: OleVariant;
end;
...
procedure TMainForm.WmRefreshData(var Message: TMessage);
begin
ClientDataSet_Main.Data := FDeltaVar;
...
end;
2。线程中:
MainForm.FDeltaVar := ClientDataSet_Thread.Data;
PostMessage(MainForm.Handle, WM_REFRESH_DATA, 0, 0);
//如果需要同步等待可改用SendMessage
//SendMessage(MainForm.Handle, WM_REFRESH_DATA, 0, 0);
//也可以用Synchronize进行同步
直接写ClientDataSet_Main.Data := ClientDataSet_Thread.Data是会出问题的。