I am trying to draw a heat map with a given input of points and amplitude of each point. The normal input size is around 400000 points, but the code draws every 15th point. The map is drawn onto a Canvas.In the XAML:<Grid x:Name=MainPanel Width=800 Height=600>    <Textbox Name=textbox Grid.Column=0/>    <Canvas Name=canvas Grid.Column=1 HorizontalAlignment=Left Height=450 Margin=70,75,0,0 VerticalAlignment=Top Width=706/></Grid>Rendering code:public static void DrawPoints(Parser parser, Canvas canvas, double radiusX, double radiusY, double thickness, double minAmplitude, double maxAmplitude)        {            double cellWidth = canvas.ActualWidth;            double cellHeight = canvas.ActualHeight;            var list = parser.Data;            // Draws every 15th point            int res = 15;            for (int i = 0; i < list.Count; i += res)            {                var location = list[i].Point;                var amplitude = list[i].Amplitude;                // Converts rgb to hsv values for representation                var color= ColorConverter.hsv2rgb(                    COLOR_START_H * (1.0 - ((amplitude - minAmplitude) / (maxAmplitude - minAmplitude))),                    COLOR_START_S, COLOR_START_V);                Point center = new Point(location.X, location.Y);                DrawEllipse(canvas, center, radiusX, radiusY,                    new SolidColorBrush(color), new SolidColorBrush(color), thickness);            }            return;        }In the DrawEllipse() function:public static void DrawEllipse(Canvas canvas, Point center, double radiusX, double radiusY, Brush fill, Brush stroke, double thickness)        {            var ellipse = new Ellipse();            ellipse.Width = radiusX * 2;            ellipse.Height = radiusY * 2;            ellipse.Fill = fill;            ellipse.Stroke = stroke;            ellipse.StrokeThickness = thickness;            Canvas.SetLeft(ellipse, center.X - radiusX);            Canvas.SetBottom(ellipse, center.Y - radiusY);            canvas.Children.Add(ellipse);            return;        }In the Main code:private void btnDraw_Click(object sender, RoutedEventArgs e){    Painter.DrawPoints(parser, canvas, 3, 3, 1, 0, 100);}The issue is that after rendering all the points onto Canvas, when I try to enter some text into textbox within the same grid, there is significant lag. What can I do to reduce the lag? 
Rendering a heat map for 400.000 points
c#;performance;wpf
DrawEllipse(canvas, center, radiusX, radiusY,                    new SolidColorBrush(color), new SolidColorBrush(color), thickness);Creating so much (partially identical) brushes is a waste of resources. Brushes can be easily cached:public static class ColorBrushLookup{    private static readonly Dictionary<Color, Brush> brushes = new Dictionary<Color, Brush>();    public static Brush ToCachedBrush(this Color color)    {        Brush brush;        if (!brushes .TryGetValue(color, out brush))        {            brush = new SolidColorBrush(color);            brush.Freeze();            brushes .Add(color, brush);        }        return brush;    }}Ellipses are relative heavy objects that support layouting, hit testing, drag&drop and so on... If you don't need such features, WPF provides more lightweight ways to draw ellipses to the screen (e.g. DrawingVisual).Using such a lightweight rendering, may also solve your lagging problem (at least if layouting is the problem).