El problema es que estas usando la funcion incorrectamente
Si vemos la
firma de la funcion, tenemos:
Código Delphi
[-]class function Exchange(var Target: Pointer; Value: Pointer): Pointer; overload; static; inline;
class function Exchange(var Target: Integer; Value: Integer): Integer; overload; static; inline;
class function Exchange(var Target: Int64; Value: Int64): Int64; overload; static; inline;
class function Exchange(var Target: TObject; Value: TObject): TObject; overload; static; inline;
class function Exchange(var Target: Double; Value: Double): Double; overload; static; inline;
class function Exchange(var Target: Single; Value: Single): Single; overload; static; inline;
class function Exchangeclass>(var Target: T; Value: T): T; overload; static; inline;
Es importante notar que el primer parametro esta pasado por referencia, de ahi el modificador
var
Quiere decir que no se puede enviar por parametro una
expresion constante
Un ejemplo de uso correcto de la funcion TInterlocked.Exchange podria ser:
Código Delphi
[-]uses
System.SyncObjs;
procedure TForm1.Button1Click(Sender: TObject);
var
A, B, C: Integer;
begin
A := 1;
B := 2;
C := TInterlocked.Exchange(A, B);
ShowMessageFmt('A = %d, B = %d, C = %d', [A, B, C]);
end;
En donde el cuadro de dialogo imprime el mensaje:
A = 2, B = 1, C = 1
Lo cual es correcto, ya que si revisamos la implementacion de TInerlocked.Exchange, simplemente invoca a otra rutina del compilador, la
AtomicExchange, donde la
documentación explica:
Cita:
Writes the given value to the target and returns the previous value of the target.
|
--
Por otro lado tené muy en cuenta lo que comento
Al Gonzalez; para responder con precision deberiamos saber el tipo de
FThread
Si bien Delphi hace bastante sencilla la transicion de 32 a 64 bits, hay algunos puntos para revisar:
Revisa esta
entrada