/// <summary> /// Safe waiting for disposables /// </summary> /// <param name="disposables"></param> /// <returns></returns> public static Task DisposeAsync(IEnumerable <IAsyncDisposable> disposables) { return(Try.Async(() => Task.WhenAll(disposables .Where(d => d != null) .Select(d => d.DisposeAsync().AsTask())))); }