示例#1
0
 private void InitClient()
 {
     try
     {
         Task.Factory.StartNew(async() => {
             // Do some work on a background thread, allowing the UI to remain responsive
             var response        = Synchronization.Client(user.ClientId).Result;
             var responseContent = await response.Content.ReadAsStringAsync();
             client = JsonConvert.DeserializeObject <Client>(responseContent);
         }).ContinueWith(task => {
             Device.BeginInvokeOnMainThread(() =>
             {
                 if (client != null)
                 {
                     AiDataStore.SaveClient(client);
                     InitConfigurations();
                 }
                 else
                 {
                     Task.Run(async() => await PopupNavigation.Instance.PushAsync(new MessageBox("Unfortunately, your account has no affiliation to any client, please contact your admin for a possible solution", MessageType.Regular, PromptPageState)));
                     AiDataStore.Logout();
                 }
             });
         }, TaskScheduler.FromCurrentSynchronizationContext());
     }
     catch (Exception ex)
     {
         Debug.Write(ex.StackTrace);
     }
 }