Skip to content

Instantly share code, notes, and snippets.

@bradphelan
Created April 14, 2014 04:34
Show Gist options
  • Save bradphelan/10616210 to your computer and use it in GitHub Desktop.
Save bradphelan/10616210 to your computer and use it in GitHub Desktop.
DisposeWith.cs
public static void DisposeWith( this IDisposable This, FrameworkElement control )
{
Observable.Merge
(
control.Events().Unloaded,
control.Dispatcher.Events().ShutdownStarted
)
.Take(1)
.Subscribe(e => This.Dispose());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment