Hi all now, for testing modified codes, i encounter a problem. please consider the following code:
procedure MyThreadNum5(Data: Pointer) var i:integer; begin 1 lockvar.BeginRead; 2 try 3 i:=NumOfRxData; 4 finally 5 lockvar.EndRead; 6 end; .... end;
the above thread freezes on line #1; while in the main vcl thread of application, the codes between beginRead/endRead and beginWrite/ endWrite are executed. i have 7 occurrences of NumOfRxData global variable in units of Delphi2006 project. all of them, are protected by closed beginRead/endRead and beginWrite/ endWrite commands. All of global variables , are defined in the main (first) unit form of application.
Unit MainUnit; .... var FormMainUnit: TFormMainUnit; LockVar:TMultiReadExclusiveWriteSynchronizer; ... (all global variables of application) implementation ... initialization RegisterClass(TFormMainUnit); LockVar:=TMultiReadExclusiveWriteSynchronizer.Create; finalization FreeAndNil (LockVar); end.
What is problem!?