private NSData ApiCallAsync(NSUrlRequest request, ref NSUrlResponse response, ref NSError error) { var _result = (NSData)null; var _done = false; { var _response = (NSUrlResponse)null; var _error = (NSError)null; var _task = NSUrlSession.SharedSession.CreateDataTask(request, (d, r, e) => { _response = r; _error = e; _result = d; _done = true; }); _task.Resume(); while (_done == false) { NSThread.SleepFor(0); } response = _response; error = _error; } return(_result); }
public void ProcessJobWithCompletion(EDQueue.EDQueue queue, NSDictionary job, System.Action <int> block) { NSThread.SleepFor(1); try { var jobStatus = ((NSString)job.ObjectForKey(new NSString("task")))?.ToString(); switch (jobStatus) { case "success": block?.Invoke((int)EDQueueResult.Success); break; case "fail": block?.Invoke((int)EDQueueResult.Fail); break; default: block?.Invoke((int)EDQueueResult.Critical); break; } } catch { block?.Invoke((int)EDQueueResult.Critical); } }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { string dbPath = FileAccessHelper.GetLocalFilePath("miemss.db"); global::Xamarin.Forms.Forms.Init(); Firebase.Core.App.Configure(); //Messaging.messaging().delegate = this; Syncfusion.SfPdfViewer.XForms.iOS.SfPdfDocumentViewRenderer.Init(); Syncfusion.SfRangeSlider.XForms.iOS.SfRangeSliderRenderer.Init(); NSThread.SleepFor(1); LoadApplication(new App(dbPath, new SQLitePlatformIOS())); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } return(base.FinishedLaunching(app, options)); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method NSThread.SleepFor(2); return(true); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. for (int i = 0; i < 30; i++) { list.Add(getItem()); } chart = new FlexChart(); chart.BindingX = "Name"; chart.Series.Add(new ChartSeries() { SeriesName = "Trucks", Binding = "Trucks,Trucks" }); chart.Series.Add(new ChartSeries() { SeriesName = "Ships", Binding = "Ships,Ships" }); chart.Series.Add(new ChartSeries() { SeriesName = "Planes", Binding = "Planes,Planes" }); chart.ItemsSource = list; chart.Palette = Palette.Coral; chart.ToolTip = null; chart.ChartType = ChartType.Line; this.Add(chart); InvokeInBackground(() => { bool flag = true; while (flag) { NSThread.SleepFor(.15); InvokeOnMainThread(() => { if (list.Count > 30) { list.RemoveAt(0); } list.Add(getItem()); chart.ItemsSource = list.ToArray(); if (!IsViewLoaded) { flag = false; } }); } }); }
partial void CancelOperation(NSObject sender) { CancellationTokenSource.Cancel(); // // Wait a few moments for the task to complete. // if (!RenameTask.IsCompleted) { for (int i = 0; i < 20 && !RenameTask.IsCompleted; i++) { NSThread.SleepFor(0.1); } } DismissController(this); }
public void reportScore(long score, string category, MTGKTapperViewController controller) { GKScore scoreReporter = new GKScore(category); scoreReporter.Value = score; scoreReporter.ReportScore(new Action <NSError> ((error) => { if (error == null) { new UIAlertView("Score reported", "Score Reported successfully", null, "OK", null).Show(); } else { new UIAlertView("Score Reported Failed", "Score Reported Failed", null, "OK", null).Show(); } NSThread.SleepFor(1); controller.updateHighScore(); })); }
public void ReportScore(long score, string category, MTGKTapperViewController controller) { var scoreReporter = new GKScore(category) { Value = score }; scoreReporter.ReportScore(error => { if (error == null) { ShowAlert("Score reported", "Score Reported successfully"); } else { ShowAlert("Score Reported Failed", "Score Reported Failed"); } NSThread.SleepFor(1); controller.UpdateHighScore(); }); }
public override void DidUpdateFocus(UIFocusUpdateContext context, UIFocusAnimationCoordinator coordinator) { var nextFocusedView = context.NextFocusedView; if (!nextFocusedView.IsDescendantOfView(TableView)) { return; } NSIndexPath indexPath = ((UITableViewFocusUpdateContext)context).NextFocusedIndexPath; if (indexPath == null) { return; } // Cancel any previously queued segues. delayedSeguesOperationQueue.CancelAllOperations(); // Create an `NSBlockOperation` to perform the detail segue after a delay. var performSegueOperation = new NSBlockOperation(); var segueIdentifier = SegueIdentifierMap[indexPath.Section][indexPath.Row]; performSegueOperation.AddExecutionBlock(() => { NSThread.SleepFor(performSegueDelay); if (performSegueOperation.IsCancelled && segueIdentifier == lastPerformedSegueIdentifier) { return; } NSOperationQueue.MainQueue.AddOperation(() => { PerformSegue(segueIdentifier, nextFocusedView); lastPerformedSegueIdentifier = segueIdentifier; TableView.SelectRow(indexPath, true, UITableViewScrollPosition.None); }); }); delayedSeguesOperationQueue.AddOperation(performSegueOperation); }
public override void ViewDidLoad() { base.ViewDidLoad(); for (int i = 0; i < 8; i++) { list.Add(getItem()); } chart.ItemsSource = list; chart.Palette = XuniPalettes.Coral; chart.Tooltip.IsVisible = false; chart.ChartType = ChartType.Line; chart.LoadAnimation.AnimationMode = AnimationMode.Point; chart.BindingX = "time"; chart.Series.Add(new Series(chart, "Trucks, Trucks", "Trucks")); chart.Series.Add(new Series(chart, "Ships, Ships", "Ships")); chart.Series.Add(new Series(chart, "Planes, Planes", "Planes")); chart.IsAnimated = true; InvokeInBackground(() => { bool flag = true; while (flag) { NSThread.SleepFor(1); InvokeOnMainThread(() => { chart.CollectionView.RemoveAt(0); chart.CollectionView.Add(getItem()); if (!IsViewLoaded) { flag = false; } }); } }); }
public static bool Activate(int pid, int wait = 5000) { NSRunningApplication app = null; for (; wait > 0; wait -= 100) { if (app == null) { app = NSRunningApplication.GetRunningApplication(pid); } if (app != null && app.FinishedLaunching) { if (app.Activate(NSApplicationActivationOptions.ActivateIgnoringOtherWindows)) { return(true); } } NSThread.SleepFor(0.1); } return(false); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { NSThread.SleepFor(1); _window = new UIWindow(UIScreen.MainScreen.Bounds); MapServices.ProvideAPIKey(Constant.GOOGLE_PLACE_APIKEY); UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, true); UINavigationBar.Appearance.BarTintColor = new UIColor((nfloat)(60.0 / 255.0), (nfloat)(90.0 / 255.0), (nfloat)(126.0 / 255.0), (nfloat)1.0); UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = UIColor.White }; #region Facebook login Profile.EnableUpdatesOnAccessTokenChange(true); Settings.AppID = Constant.FacebookAppId; Settings.DisplayName = Constant.DisplayName; // NSError configureError; // Context.SharedInstance.Configure (out configureError); // if (configureError != null) { // Console.WriteLine ("Error configuring the Google context: {0}", configureError); // } // // Invite.ApplicationDidFinishLaunching (); // // return true; // This method verifies if you have been logged into the app before, and keep you logged in after you reopen or kill your app. return(ApplicationDelegate.SharedInstance.FinishedLaunching(application, launchOptions)); #endregion }
public void DoSomeWorkThatTakesLong() { // we don't have anything to do. Simulate a long-running task by calling sleep. // That is okay here because we are in a demo and not running on the main thread. NSThread.SleepFor(2.0); }
public async void checkHighest(int sc, string level) { string catString = "com.commtech.inapppurchTest.StageScores"; //com.commtech.inapppurchTest. GKLocalPlayer xx = GKLocalPlayer.LocalPlayer; GKLeaderboard Leaderboard = new GKLeaderboard(new [] { xx.PlayerID }) { Identifier = catString }; var ss = Leaderboard.LocalPlayerScore; //var scores = await Leaderboard.LoadScoresAsync (); var oldScore = 0; //ss.Value; //var oldScore = current.Value; // if (ss.Value != null) { // // oldScore = (int)ss.Value; // } // var Category = Convert.ToInt64( level.Substring (1, 1)); // // Console.WriteLine ("XXXXXXXXXXXXXXXXXXMXMXMXMXMMXMXMXXXXXXMXMXMXXXXXXXX"); // // if (oldScore == null) { var newScore = new GKScore(catString) { Value = sc }; newScore.ReportScore(new Action <NSError> ((error) => { if (error == null) { Console.WriteLine("YYYYYYYYYYYYYYYYYYYYYYYYYYBBBYYYBYBYBYBYYyy"); //new UIAlertView ("Score reported", "Score Reported successfully", null, "OK", null).Show (); } else { Console.WriteLine("XXXXXXXXXXXXXXXXXXMXMXMXMXMMXMXMXXXXXXMXMXMXXXXXXXX"); //new UIAlertView ("Score Reported Failed", "Score Reported Failed", null, "OK", null).Show (); } NSThread.SleepFor(1); //controller.updateHighScore (); })); // // Console.WriteLine ("score::" + newScore.Value); // await GKScore.ReportScoresAsync(new [] { newScore }); //// // } // else if (sc > oldScore) { // // gcm.reportScore (sc, car); // var newScore = new GKScore (catString) { // Value = sc // // }; // // //await GKScore.ReportScoresAsync(new [] { newScore }); // // } //GameCenterManager1 gcm = new GameCenterManager1 (); }