コード例 #1
0
 public void RunCode(Object sender, EventArgs ea)
 {
     Backendless.Data.Of($"{Operations.TableName}").FindFirst(new AsyncCallback <Dictionary <String, Object> >(
                                                                  savedObj =>
     {
         Dictionary <String, Object> obj = savedObj;
         obj["Age"]  = new Random().Next(2, 2000);
         obj["Name"] = HelperCRUD.RandomString(new Random().Next(3, 16));
         try
         {
             Backendless.Data.Of($"{Operations.TableName}").Save(obj);
             Device.InvokeOnMainThreadAsync(() =>
             {
                 DisplayAlert("Success", "The record has been updated", "Ok");
             });
         }
         catch (Exception e)
         {
             Device.InvokeOnMainThreadAsync(() => { DisplayAlert("Error", e.Message, "Ok"); });
         }
     },
                                                                  fault =>
     {
         Device.InvokeOnMainThreadAsync(() => { DisplayAlert("Error", fault.Message, "Ok"); });
     }));
 }
コード例 #2
0
        public async void RunCode(Object sender, EventArgs ea)
        {
            await Task.Run(() =>
            {
                Dictionary <String, Object> obj = new Dictionary <String, Object>();
                obj["Age"]  = new Random().Next(2, 50);
                obj["Name"] = HelperCRUD.RandomString(new Random().Next(3, 16));

                Backendless.Data.Of($"{Operations.TableName}").Save(obj, new AsyncCallback <Dictionary <String, Object> >(
                                                                        savedObj =>
                {
                    obj = savedObj;
                    Device.InvokeOnMainThreadAsync(() =>
                    {
                        DisplayAlert("Success", "The record has been created", "Ok");
                    });
                },
                                                                        async fault =>
                {
                    await DisplayAlert("Error", fault.Message, "Ok");
                }));
            });
        }