WPF set 0,0 dashes to Pen DashStyle will cause high CPU usage
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: All
* Windows version: All (Win10, Win7)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
**Problem description:**
WPF will cause high CPU usage when we set `new DashStyle(new double[] { 0, 0 }, 0)` to the Pen DashStyle.
```csharp
protected override void OnRender(DrawingContext drawingContext)
{
var pen = new Pen()
{
Brush = Brushes.Black,
DashStyle = new DashStyle(new double[] { 0, 0 }, 0),
Thickness = 10,
};
var geometry = new LineGeometry(new Point(0, 0), new Point(500, 0));
drawingContext.DrawGeometry(Brushes.Beige, pen, geometry);
base.OnRender(drawingContext);
}
```
It seems costs too many resources to render in render thread.
**Actual behavior:**
High CPU usage
**Expected behavior:**
**Minimal repro:**
See https://github.com/lindexi/lindexi_gd/tree/5137479a45ce3f52ff1cf5c5d6ed0c20dfbeaeb3/KolefijurfeLonaynallcay
Step:
1. Open the Task Manager.
2. Clone and run the code.
3. Moving your mouse on the application MainWindow.
Then you can find the KolefijurfeLonaynallcay.exe takes up a lot of CPU resources.
Contributor guide
Assessment
This issue has not been assessed yet.