//private async void ImportVendorsAndCategories() //{ // Message msg = new Message(); // msg = handler.ObtainMessage(); // //msg.Arg1 = 0; // //handler.SendMessage(msg); // foxWebSvc.FoxSvcSql foxSql = new foxWebSvc.FoxSvcSql(); // vendors = foxSql.GetVendorList("192.168.100.97"); // //txtdbResult.Text += "Import complete."; // //progBar.Hide(); // //return true; // msg.Arg1 = 2; // //msg.Arg2 = vendors; // handler.SendMessage(msg); //} private async void ImportVendorsAndCategories2() { TextView txtdbResult = FindViewById <TextView>(Resource.Id.txtdbResult); ProgressDialog progBar = new ProgressDialog(this); progBar.SetCancelable(false); progBar.SetMessage("Getting data from server(7)..."); progBar.SetProgressStyle(ProgressDialogStyle.Spinner); progBar.Show(); var thread = new System.Threading.Thread(new ThreadStart(delegate { FoxScannerSvc.FoxScannerSvc foxSql = new FoxScannerSvc.FoxScannerSvc(); vendors = foxSql.GetVendorList(); })); thread.Start(); while (thread.ThreadState == ThreadState.Running) { await Task.Delay(4000); } RunOnUiThread(() => { txtdbResult.Text = "One moment please..."; }); progBar.Dismiss(); VendorCatImportComplete(); }
// ================================================================== private void DownloadVendorCatLists() { // ============================================================== // Use FoxScannerSvc to get string of vendor codes + names // ============================================================== Message msg = new Message(); svcCallHandler = new EventandlerSvcCallComplete(this); msg = svcCallHandler.ObtainMessage(); ProgressDialog progBar = new ProgressDialog(this); progBar.SetCancelable(false); progBar.SetTitle("Synchronizing..."); progBar.SetIcon(Resource.Drawable.iconChill64); progBar.SetMessage("Downloading vendor list from server"); progBar.SetProgressStyle(ProgressDialogStyle.Spinner); progBar.Show(); var thread = new System.Threading.Thread(new ThreadStart(delegate { try { FoxScannerSvc.FoxScannerSvc foxSql = new FoxScannerSvc.FoxScannerSvc(); vendors = foxSql.GetVendorList(); RunOnUiThread(() => { progBar.SetMessage("Downloading category list from server"); }); categories = foxSql.GetCategoryList(); RunOnUiThread(() => { progBar.Dismiss(); }); msg.Arg1 = 0; msg.Arg2 = 1; svcCallHandler.SendMessage(msg); } catch (Exception ex) { RunOnUiThread(() => { progBar.Dismiss(); }); msg.Arg1 = 1; msg.Arg2 = 1; svcCallHandler.SendMessage(msg); } })); thread.Start(); } // ImportVendorAndCategories()