Home Ask Login Register

Developers Planet

Your answer is one click away!

Dofan February 2016

Why does this simple C# UWP Win2D program occasionally fail to render an image

Hi, my first post so please be gentle :)

I have written this simple C# UWP Win2D program that on occasions randomly fails to render the image on screen. The program runs without problems roughly 90% of the time, and as it should, it renders the image, oddly though every now and then it fails to render it.

When it fails, it still clears the canvas to the correct colour but it does not render anything else. The program seems to be running properly but when I place a break point on either the draw method or the update method a break does not occur.

'Break all' does break the program but it informs me "Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code)"

I hope this explains the situation that I am currently facing, I have included the code that is causing this problem, hopefully someone more knowledgeable than me can help me find a remedy.

Here is my XAML code ...


    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            ClearColor="Bisque" Update="canvas_Update" Draw="canvas_Draw" CreateResources="canvas_CreateResources"

And here is the C# code behind ...

public sealed partial class MainPage : Page


AchmadJP February 2016

I think the problem is in here

private void canvas_CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args)

When using async, my teacher told me to always use await and async function. Because this will cause problem.

Some reading source : https://msdn.microsoft.com/en-us/library/hh191443.aspx

Post Status

Asked in February 2016
Viewed 1,139 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life