dotnet / dotnet/wpf

[API Proposal] Making the RenderTargetBitmap inherit IDisposable

Open
#7,177 5 comments 2 reactions 0 assignees View on GitHub
API suggestion
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

The RenderTargetBitmap will cature the `_wicSource` handler which will release slowly by GC. WPF will throw COM Exception when create RenderTargetBitmap too fast.

Making the RenderTargetBitmap inherit IDisposable. Developers can better control the release of memory.

## API Proposal

1. Making the RenderTargetBitmap inherit IDisposable

```csharp
public class RenderTargetBitmap : IDisposable
```

2. Add the `AsDisposable` method

```csharp
public class RenderTargetBitmap
{
public IDisposable AsDisposable(){}
}
```

Add the `AsDisposable` method can make the Analyzer happy. The Analyzer will not keep alerting that the IDisposable object may be a potential memory leak.

See https://github.com/dotnet/wpf/issues/3067#issuecomment-1065849036

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.