JackY
JackY

Reputation: 51

UWP App is automatically terminated when sleeping then waking up device

My UWP contains one Canvas view for drawing. I am using win2d for drawing in this view. If I leave this view as activated view then sleep/wake up device, my app will be terminated with exception:

System.Exception: Objects used together must be created from the same factory instance.

I don't catch or do anything with Suspend and Resume event. If I leave other view as actived, this problem will not happen. Have any one know about this problem ?

Upvotes: 3

Views: 450

Answers (1)

Shawn Hargreaves
Shawn Hargreaves

Reputation: 264

My guess is that your app is probably encountering a lost graphics device. Win2D will recover from this automatically, create a new device, and raise the CreateResources event again to let you know to create new resources for this new device. I suspect you are not completely recreating everything in your CreateResources handler, so you end up using some object from your old no longer valid device with some other object from the new valid device.

More info: http://microsoft.github.io/Win2D/html/HandlingDeviceLost.htm

Upvotes: 3

Related Questions