Skip to content

is dispose called when exception occurs in ctor? #103415

Answered by elgonzo
Symbai asked this question in Q&A
Discussion options

You must be logged in to vote

I don't understand. The this keyword is unrelated. How/why do you think that the this keyword might matter here? Scratch that. I misread your comment and didn't notice you used "this" only as an anchor for a link to an article about finalizers...

Yes. The finalizer is guaranteed to be run (once the GC comes around to collect and process the finalization queue).

Because, for the ctor to be executed, the instance itself has to already exist (otherwise you wouldn't be able to access instance members or use the this keyword in ctors). Once an instance of a type with a finalizer exists and cannot be accessed by any possible continuation of execution (other than the running of finalizers thems…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Symbai
Comment options

@elgonzo
Comment options

Answer selected by Symbai
@elgonzo
Comment options

@elgonzo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants