Windows SDK with a Windows 10 Universal App hangs

I’m trying to use the Windows SDK in a Windows 10 Universal App (specifically, one which will run on Windows 10 IoT Core on a Raspberry Pi 3), but I’m finding that all calls to the API cause their thread to effectively hang.

As an example, a call like:

bool loginStatus = ParticleCloud.SharedCloud.TokenLoginAsync("<my_token>").Result

Works perfectly if I run it in a Command Line app, but when used in a Universal app, the same call never returns.

I’m probably missing something simple (hopefully) … Has anyone else got this working in a Universal app targeting Windows 10 IoT Core?

OK, so when doing a UWP build, it seems that intentionally making the calls Synchronous using .result is the problem. Making the calls explicitly await (which must be done in a method tagged async, and therefore cannot be done in events or during initialisation) resolves this.

It would be nice to be able to just call on .result though, I’m dealing with all UI updates in DispatcherTimer Tick events, so now have to resort to a spaghetti mess of additional calls to get the updates I need.

Mikel,

I’ll take a look at this to see why these calls are hanging.

Is there a reason you are handling UI updates yourself? The ParticleDevice inherits from INotifyPropertyChanged, so this all happens seamlessly.

1 Like

Thanks @justinmy - I’ll look at working via the Property Notifiers, definitely the right way to do it if I can get it going :smile:

@MikeI, take a look at the code for Particle Tinker app for Windows.