Multithreading with Xamarin

Xamarin support for cloudbase.ioThe Xamarin client library – like all other helper classes – executes HTTP calls to the REST API in the background, on a separate thread, then calls back the application using a delegate.

The delegate is executed on the new thread started for the HTTP call, because of this it won’t be able to make changes to the application UI directly. This is because you may need to perform some additional operations on the data returned by the API call without blocking the app’s main thread.

Xamarin provides a simple method to execute code on the main UI thread, effectively returning from the HTTP thread. From an iOS application the NSObject class contains a method called InvokeOnMainThread, which receives a delegate and can be used to make changes to the UI; in Android the Activity class contains a similar RunOnUiThread method.

To get started simply register for a account and download our client library from GitHub or the Xamarin component store.

  • PK

    Why its no a Xamarin component store?

    • cloudbase_io

      Hi PK. We are waiting for approval. The component is submitted and hopefully should be up today.