/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_randy?.Dave != null) { _randy.Dave.DesktopBackgroundChanged -= OnDesktopBackgroundChanged; } _randy?.Dispose(); _randy = null; if (_dave != null) { _dave.DesktopBackgroundChanged -= OnDesktopBackgroundChanged; _dave?.Dispose(); _dave = null; } } _disposed = true; Current = null; }
/// <summary> /// Initializes a new instance of the <see cref="Desktop"/> class. /// </summary> private Desktop() { _randy = new MessagePumpsDaddy(); Task.Run(async() => { await _randy.InitializeAsync(Factory); _randy.Dave.DesktopBackgroundChanged += OnDesktopBackgroundChanged; }); }