I have to do very heavy processing when updating SKCanvasView.
At that time, the UI thread stops every time.
So, I'd like to implement it using asynchronous processing, but would you please teach me?
XAML:
<Grid>
<skia:SKCanvasView x:Name="canvasView" PaintSurface="OnPaintCanvas" EnableTouchEvents="True" Touch="OnTouch"/>
</Grid>
Code Behind:
private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e)
{
SKImageInfo info = e.Info;
SKSurface surface = e.Surface;
SKCanvas canvas = surface.Canvas;
int surfaceWidth = info.Width;
int surfaceHeight = info.Height;
SKPoint surfaceSize = new SKPoint(surfaceWidth, surfaceHeight);
canvas.Clear(PaintColors.DefaultBackground);
if (!prevSurfaceSize.Equals(surfaceSize) || canvasRepaintFlag)
{
//Debug.WriteLine("Repaint");
//Re-painting everything when the surface size changes, or when canvasRepaintFlag is True
layerA = new Canvas((int)surfaceSize.X, (int)surfaceSize.Y);
//Convert Vectormap to Bitmap and paint Bitmap for paintings (very heavy)
canvas.DrawBitmap(vectormap.ToBitmap(layerA), 0, 0);
canvasRepaintFlag = false;
}...
}