Want more features on Pastebin? Sign Up, it's FREE!
Guest

http://stackoverflow.com/questions/17652922/automatically-fr

By: a guest on Jul 15th, 2013  |  syntax: Delphi  |  size: 0.37 KB  |  views: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. type myClass = class(TMyInterfacedObject)
  2.          public
  3.             destructor Destroy; override;
  4.      end;
  5.  
  6. destructor myClass.Destroy;
  7. begin
  8.    do cleanup
  9. end;
  10.  
  11. procedure MyProcedure;
  12. var IGuard: iInterface;
  13. begin
  14.    ...
  15.    IGuard := myClass.Create(acquire resources);
  16. ....
  17. end;  // IGuard is automatically decremented here and myClass destructor is called
clone this paste RAW Paste Data