i have, but that did not solve the problem.
i have read few articles regarding this and finally understand that i
got this error because i tried to access the interface method from a
different thread. i have manage to get around it by using timer.
everytime a thread try to access a method, the main thread save the
parameters locally and activate the timer. below is my code
------ code ------
procedure Thread1.Method1(Param1: String);
begin
//Do something
end;
procedure Thread1.OtherThreadCallMethod1(Param1: String);
begin
FParam1 := Param1;
Timer1.enabled := True;
end;
procedure Thread1.Timer1Method1Timer(Sender: TObject);
begin
Timer1.enabled := False;
method1(FParam1);
end;
This seems to solve the problem, but it doesn't look so neat. is there
a way to marshal the interface between client and server computers so
that its method can be called from any thread.
below is my original code. the client connect to svr through
TSocketConnection
// client
procedure CLient1.connectsvr;
begin
SocketConnection.Connected := True;
FClient := IClient.Create;
SocketConnetion.AppServer.RegisterClient(FClient);
end;
// server thread1
procedure SvrThread1.RegisterClient(Client: OleVariant);
begin
FClient := Client;
end;
procedure SvrThread1.clientmethod1(Param: String);
begin
FClient.clientmethod1(Param);
end;
// svr thread2
procedure svrthread2.clientmethod1;
begin
SvrThread1.clientmethod1('');
end;
thanks for any suggestion
rey