Subject how to implement thread safe UDFs ?
Author Kamlesh
dear friends

what can be said the better way to implement thread safe UDFs ?
can i make my functions thread safe by using CriticalSection in following
manner ?

// following is my UDF Library Unit

unit MyUDFUnit;

interface
uses
SysUtils, SyncObjs;

Var
FCriticalsection: TCriticalSection;

implementation

Procedure EnterFunction;
Begin
FCriticalsection.Enter;
End;

Procedure ExitFunction;
Begin
FCriticalsection.Leave;
End;

Function MyFunction(ACString:PChar):Integer; cdecl; export;
Begin
EnterFunction;

// do some work here

ExitFunction;
End;

exports
MyFunction;

Initialization
FCriticalsection := TCriticalSection.Create;
Finalization
FCriticalsection.Free;
End.

//-----------------------


Thanks
Kamlesh