I am writing code that is really fast and works great with Acr User dialogs.
I am using the depedency service, and here is my complete sample code.
PCL Code
void CallService ()
{
Device.BeginInvokeOnMainThread (() => UserDialogs.Instance.ShowLoading ("Loading ...", MaskType.Black));
Task.Run (async () => {
await DependencyService.Get<IJsonMethods> ().Load ("SERVICE_URL");
}).ContinueWith (result => Device.BeginInvokeOnMainThread (() => {
UserDialogs.Instance.HideLoading ();
}
})
);
}
Interface
public interface IJsonMethods
{
Task Load(string url);
}
public async Task Load (string url)
{
try{
using (var http = new HttpClient (new NativeMessageHandler ())) {
var x = await http.GetAsync (new Uri (url));
string res = await x.Content.ReadAsStringAsync ();
MainViewModel.JsonList = JsonConvert.DeserializeObject<ArticleClass.RootObject> (res);
}
}catch (Exception ex) {
MainViewModel.JsonList = null;
}
}