TkbmMWLock.BeginWrite is freeze

Home Forums kbmMW TkbmMWLock.BeginWrite is freeze

Viewing 1 reply thread
  • Author
    Posts
    • #55422
      TomYU
      Participant

      Nested execution of the BeginWrite method, the program will freeze.
      eg.

      FLock: TkbmMWLock;

      FLock.BeginWrite;

      try

      FLock.BeginWrite;

      try

      finally

      FLock.EndWrite;

      end;

      finally

      FLock.EndWrite;

      end;

      Delphi 10.3.3

      kbmMW 5.13.00

      • This topic was modified 4 years, 11 months ago by TomYU.
      • This topic was modified 4 years, 11 months ago by TomYU.
    • #55468
      kimbomadsen
      Keymaster

      Hi,

      It definitely will not block. kbmMWLock supports nested locking, both for reader and writer. But do you do something in the … parts that may synchronize with the VCL thread (a typical mistake)?

      This simple code runs perfectly:

      procedure TForm2.FormCreate(Sender: TObject);
      var
         FLock:TkbmMWLock;
      begin
           FLock:=TkbmMWLock.Create;
           try
              FLock.BeginWrite;
      
              try
                 FLock.BeginWrite;
                 try
                 finally
                    FLock.EndWrite;
                 end;
      
              finally
                 FLock.EndWrite;
              end;
           finally
              FLock.Free;
           end;
      end;
Viewing 1 reply thread
  • You must be logged in to reply to this topic.