LooterKaka
LooterKaka

Reputation: 45

MEF and WPF. Lifetime of lazy(of T)?

1st i'm newbie
I import object/Class using lazy()
now my questions are

1) what is the lifetime of my object?
2) how this object disposes?
3) if Disposed manually can MEF later reinitialize it when i issue object.value?

Upvotes: 2

Views: 337

Answers (1)

Daniel Plaisted
Daniel Plaisted

Reputation: 16744

Generally the lifetime of the object is the same as the lifetime of the container, and it is disposed with the container. The lifetime/disposal can happen earlier in some situations for NonShared parts. Here is an answer that goes into more detail on MEF part lifetime.

For your third question, the answer is no. Depending on what you're trying to do, ExportFactory might be what you're looking for. It will let you create and dispose multiple copies of a given export.

Upvotes: 1

Related Questions