namespace ConsoleApplication4;
type
Resource = class(IDisposable)
method Dispose;
begin
writeLn('Resource.Dispose');
end;
end;
Program = class
public
class method Main(args : array of String) : Int32;
begin
using res := new Resource do
begin
writeLn('object: ' + res.ToString);
raise new Exception('text');
end;
end;
end;
end.
Output:
object: ConsoleApplication4.Resource
Unhandled Exception: System.Exception: text
at ConsoleApplication4.Program.Main(String[] args) in c:\users\alexey\documents\visual studio 2015\Projects\ConsoleApplication4\ConsoleApplication4\Program.pas:line 21
However, if the exception is unhandled, execution of the finally block is dependent on how the exception unwind operation is triggered. That, in turn, is dependent on how your computer is set up.
curious, I wasn’t aware of this. So that might be as designed (and, frankly, out of out hangs) on .NET. Not sure about Island.
I assume it does get executed ok if the exception gets caught later on?