Skip to content

How to dispose of AvaloniaUI Application #331

Answered by JordanMarr
matthewcrews asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Matthew!

In the world of add-ins, the AppDomain belongs to the parent app (Excel), so you have to be careful not to call your app init code more than once.

First of all, you have some control over the conditions that shutdown your app via the ShutdownMode property:

    override this.OnFrameworkInitializationCompleted() =
        match this.ApplicationLifetime with
        | :? IClassicDesktopStyleApplicationLifetime as desktop ->         
            let view = MainView()
            desktop.MainWindow <- view
            desktop.ShutdownMode <- ShutdownMode.OnMainWindowClose

Values are:

  • ShutdownMode.OnMainWindowClose
  • ShutdownMode.OnExplicitShutdown
  • ShutdownMode.OnLastWindowClose

I'v…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@matthewcrews
Comment options

@JordanMarr
Comment options

@JordanMarr
Comment options

@matthewcrews
Comment options

@JordanMarr
Comment options

Answer selected by matthewcrews
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