The AccountsÂSettingsÂPane.
method shows the accounts settings pane and returns immediately. How do you know when the user has closed the pane?
If the user selects one of your commands, you get a notification in the form of the Invoked
event on that command. But what if the user closes the pane without selecting anything?
Instead of using the AccountsÂSettingsÂPane.
method, use the AccountsÂSettingsÂPane.
method. The ShowÂManageÂAccountsÂAsync
method does the same thing as AccountsÂSettingsÂPane.
, except that it returns an IAsyncÂAction
which completes when the pane is closed (for whatever reason).
(Dirty secret: Really, it’s the other way around. The AccountsÂSettingsÂPane.
method just calls the AccountsÂSettingsÂPane.
method. and throws away the IAsyncAction
.)
Note that the more general version of this pattern (“I want to open [something], let the user interact with it for a while, and wait for them to close it”) is questionable at best, at least in the case where [something] involves Explorer or any web browser. The user might navigate away or start doing something else, and then, hours later, alt-tab back to your window only to find it frozen because you’re still waiting for them to close the window (that they forgot you opened). Worse, the program might just forward to its “main” instance and terminate immediately. Raymond previously discussed this in the context of Explorer in 2011.