Jump to content
PatV

SetThreadDataFactory

Recommended Posts

Hi,

 

could someone tell me what's wrong here, I'm returning an IInterface  as needed so ... 

 

[dcc32 Error] clsInit.pas(313): E2250 There is no overloaded version of 'SetThreadDataFactory' that can be called with these arguments

 

( in OtlThreadPool  ; TOTPThreadDataFactoryFunction = function: IInterface; )


function TFConfig.CreateThreadPool(aHandle : THandle ; aConfig : rConnectionConfig ;  aValue: string) : iOmniThreadPool;
begin
  result  := otlThreadPool.CreateThreadPool(aValue);
  result.MaxExecuting := result.NumCores;
  result.SetThreadDataFactory

  (
     function  : IInterface
     begin
       result:=CreateConnectionPoolData(aHandle,aConfig);
     end
  );

end;

 

I have defined  CreateConnectionPoolData as follow

 

function CreateConnectionPoolData(const aHandle : THandle ; const aConfig : rConnectionConfig) : IInterface;
var
  aPool : IConnectionPoolData;
begin
  aPool := TConnectionPoolData.Create;
  aPool.WithHandle(aHandle).WithConnectionConfig(aConfig);
  result:=aPool;
end;

 

  IConnectionPoolData = interface
    function WithHandle(const aValue : HWND) : IConnectionPoolData ;
    function WithConnectionConfig(aValue : rConnectionConfig) : IConnectionPoolData ;
  end;

 

Thanks

 

Patrick

 

 

 

 

 

 

 

 

Edited by PatV
update

Share this post


Link to post

Ah, SetThreadDataFactory actually doesn't support taking an anonymous function as an argument. An oversight that I should fix in a future.

 

So - pass a normal function or method name to SetThreadDataFactory, not an anonymous method.

 

(And I will amend my answer to your previous question on that topic.)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×