Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Threading issues in App.cs OnSleep()

$
0
0

I'm using PCL Storage to write my JSON data to the device, and it's working great for the most part.

However it is failing during the App OnSleep() event.

The functions CreateFileAsync() and WriteAllTextAsync are of course asynchronous

So when the device goes to sleep the OS kills the main thread before the contents get written and I end up with a blank file.

What's the best way to handle housekeeping and saving when the app goes to sleep?

Can these functions run synchronously? I tried removing "await" but I get compiler errors, I think because of the Task<> structure


Viewing all articles
Browse latest Browse all 77050

Trending Articles