当前位置: 首页>>代码示例>>C#>>正文


C# NSAutoreleasePool.InvokeOnMainThread方法代码示例

本文整理汇总了C#中NSAutoreleasePool.InvokeOnMainThread方法的典型用法代码示例。如果您正苦于以下问题:C# NSAutoreleasePool.InvokeOnMainThread方法的具体用法?C# NSAutoreleasePool.InvokeOnMainThread怎么用?C# NSAutoreleasePool.InvokeOnMainThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NSAutoreleasePool的用法示例。


在下文中一共展示了NSAutoreleasePool.InvokeOnMainThread方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowProgressDialog

        public static void ShowProgressDialog(string title, string message, Action action, Action finalize) {
            UIAlertView dialog = new UIAlertView(title, message, null, null);

            dialog.Show();
			_indicatorViewLeftCorner.Hidden = false;

            ThreadPool.QueueUserWorkItem(delegate
            {
                // Run the given Async task
                action();

                // Run the completion handler on the UI thread and remove the spinner
                using (var pool = new NSAutoreleasePool())
                {
                    try
                    {
                        pool.InvokeOnMainThread(() =>
                        {
                            dialog.DismissWithClickedButtonIndex(0, true);

							_indicatorViewLeftCorner.Hidden = true;
                            finalize();
                      });
                    }
					catch (Exception ex){
						Insights.Report(ex);
                    }
                }
            });

        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:31,代码来源:DialogHelper.cs

示例2: HandleGetPicturesCompleted

		private void HandleGetPicturesCompleted (object sender, Loewenbraeu.Data.Service.GetPicturesCompletedEventArgs args)
		{
			bool error = ServiceAgent.HandleAsynchCompletedError (args, "GetEvents");
			using (var pool = new NSAutoreleasePool()) {
			
				pool.InvokeOnMainThread (delegate	{
					Util.PopNetworkActive ();
					if (error)
						return;
					
					List<Picture> result = args.Result.ToList ();
					ShowGalery (result);
				});
			}
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:15,代码来源:GalleryController.cs

示例3: HandleIsDeclinedByRestaurantCompleted

		private void HandleIsDeclinedByRestaurantCompleted (object sender, IsDeclinedByRestaurantCompletedEventArgs args)
		{
			bool error = ServiceAgent.HandleAsynchCompletedError (args, "GetEvents");
			
			using (var pool = new NSAutoreleasePool()) {
			
				pool.InvokeOnMainThread (delegate	{
					Util.PopNetworkActive ();
					if (error)
						return;
					
					if (args.Result == true) {
						_reservation.Status = StatusArt.DeclinedByRestaurant;
						ReservationRepository.Update (_reservation);
						ShowConfirmReservationView (_reservation);
						//StopTimer ();
					} else {
						ShowCodeConfirmView (_reservation);
					}
				});
			}
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:22,代码来源:ReservierungController.cs

示例4: iOSNavigationManager

 public iOSNavigationManager(ITinyMessengerHub messageHub)
 {
     _messageHub = messageHub;
     _messageHub.Subscribe<MobileNavigationManagerCommandMessage>((m) => {
         using(var pool = new NSAutoreleasePool())
         {
             pool.InvokeOnMainThread(() => {
                 switch(m.CommandType)
                 {
                     case MobileNavigationManagerCommandMessageType.ShowPlayerView:
                         var navCtrl = (SessionsNavigationController)m.Sender;
                         CreatePlayerView(navCtrl.TabType);
                         break;
                     case MobileNavigationManagerCommandMessageType.ShowEqualizerPresetsView:
                         CreateEqualizerPresetsView(null);
                         break;
                     case MobileNavigationManagerCommandMessageType.ShowPlaylistView:
                         CreatePlaylistView(null);
                         break;
                 }
             });
         }
     });
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:24,代码来源:iOSNavigationManager.cs

示例5: HandleQuizCompleted

		void HandleQuizCompleted (object sender, GetQuizCompletedEventArgs args)
		{
			bool error = ServiceAgent.HandleAsynchCompletedError (args, "GetQuiz");
			using (var pool = new NSAutoreleasePool()) {
			
				pool.InvokeOnMainThread (delegate	{
					Busy = false;
					if (error)
						return;
					
					Model.Quiz result = args.Result.ToLbkQuiz ();
					//result.Id = 14;
					_qvc = new QuizViewController (result);
					this.NavigationController.PushViewController (_qvc, true);
				});
			}
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:17,代码来源:QuizStartViewController.cs

示例6: HandleGetMenuLastUpdateCompleted

		void HandleGetMenuLastUpdateCompleted (object sender, GetMenuLastUpdateCompletedEventArgs args)
		{
			bool error = ServiceAgent.HandleAsynchCompletedError (args, "GetMenuLastUpdate");
			using (var pool = new NSAutoreleasePool()) {
				
				pool.InvokeOnMainThread (delegate	{
					Busy = false;
					if (error)
						return;
					var updateDate = args.Result;
					this.Display(updateDate);
					
				});
			}
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:15,代码来源:SpeisekarteViewController.cs

示例7: LinkApp

 public void LinkApp(object view)
 {
     using (NSAutoreleasePool pool = new NSAutoreleasePool())
     {
         pool.InvokeOnMainThread(() =>
         {
             var account = DBAccountManager.SharedManager.LinkedAccount;
             if (account == null)
             {
                 DBAccountManager.SharedManager.LinkFromController((UIViewController)view);
             }
         });
     }
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:14,代码来源:iOSDropboxService.cs

示例8: ExecuteCommandThread

		private void ExecuteCommandThread()
		{
			using (var pool = new NSAutoreleasePool())
			{
				pool.InvokeOnMainThread(delegate
				{
					if (Command.CanExecute(CommandParameter))
						Command.Execute(CommandParameter);
					
					Animating = false;
				});
			}
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:13,代码来源:LoadMoreElement.cs

示例9: RequestAlwaysAuthorization

      void RequestAlwaysAuthorization()
      {
          if (!RequestLocationPermission)
              return;

          if (isPromptingLocationPermission)
              return;
          isPromptingLocationPermission = true;

          CLAuthorizationStatus status = CLLocationManager.Status;
          if(status ==CLAuthorizationStatus.AuthorizedWhenInUse || status == CLAuthorizationStatus.Denied)
          {
              string title = (status == CLAuthorizationStatus.Denied) ? "Location services are off" : "Background location is not enabled";
              string message = "To use background location you must turn on 'Always' in the Location Services Settings";

              using (var pool = new NSAutoreleasePool())
              {
                  pool.InvokeOnMainThread(() => {
                      UIAlertView alertView = new UIAlertView(title, message, null, "Cancel", "Settings");

                      alertView.Clicked += (sender, buttonArgs) => 
                      {
                          if (buttonArgs.ButtonIndex == 1)
                          {
                              // Send the user to the Settings for this app
                              NSUrl settingsUrl = new NSUrl(UIApplication.OpenSettingsUrlString);
                              UIApplication.SharedApplication.OpenUrl(settingsUrl);
                          }
                          isPromptingLocationPermission = false;
                      };

                      alertView.Show();
                  });
              }
          }
          else if (status == CLAuthorizationStatus.NotDetermined)
          {
              locationManager.RequestAlwaysAuthorization();
          }
      }
开发者ID:JPHBrivo,项目名称:xamarin-plugins,代码行数:40,代码来源:GeofenceImplementation.cs

示例10: GeofenceImplementation

      /// <summary>
      /// Geofence plugin iOS implementation
      /// </summary>
      public GeofenceImplementation()
      {

          mGeofenceResults = new Dictionary<string, GeofenceResult>();

          using (var pool = new NSAutoreleasePool())
          {
              pool.InvokeOnMainThread(() => {
                  locationManager = new CLLocationManager();
                  locationManager.DidStartMonitoringForRegion += DidStartMonitoringForRegion;
                  locationManager.RegionEntered += RegionEntered;
                  locationManager.RegionLeft += RegionLeft;
                  locationManager.Failed += OnFailure;
                  locationManager.DidDetermineState += DidDetermineState;
                  locationManager.LocationsUpdated += LocationsUpdated;
              });
          } 
          string priorityType = "Balanced Power";
          switch(CrossGeofence.GeofencePriority)
          {
              case GeofencePriority.HighAccuracy:
                  priorityType = "High Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyBest;
                  break;
              case GeofencePriority.AcceptableAccuracy:
                  priorityType = "Acceptable Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
                  break;
              case GeofencePriority.MediumAccuracy:
                  priorityType = "Medium Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyHundredMeters;
                  break;
              case GeofencePriority.LowAccuracy:
                  priorityType = "Low Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyKilometer;
                  break;
              case GeofencePriority.LowestAccuracy:
                  priorityType = "Lowest Accuracy";
                  locationManager.DesiredAccuracy = CLLocation.AccuracyThreeKilometers;
                  break;
              default:
                  locationManager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation;
                  break;
          }
          System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Location priority set to", priorityType));
    
          if(CrossGeofence.SmallestDisplacement>0)
          {
              locationManager.DistanceFilter = CrossGeofence.SmallestDisplacement;
              System.Diagnostics.Debug.WriteLine(string.Format("{0} - {1}: {2} meters", CrossGeofence.Id, "Location smallest displacement set to", CrossGeofence.SmallestDisplacement));
          }

         

          if (locationManager.MonitoredRegions.Count > 0 && IsMonitoring)
          {

              NSSet monitoredRegions = locationManager.MonitoredRegions;
             

              foreach (CLCircularRegion region in monitoredRegions)
              {
                  //If not on regions remove on startup since that region was set not persistent
                  if (!Regions.ContainsKey(region.Identifier))
                  {
                      locationManager.StopMonitoring(region);
                  }
                  else
                  {
                      locationManager.RequestState(region);
                  }
                 
              }

              locationManager.StartMonitoringSignificantLocationChanges();

              string message = string.Format("{0} - {1} {2} region(s)", CrossGeofence.Id, "Actually monitoring", locationManager.MonitoredRegions.Count);
              System.Diagnostics.Debug.WriteLine(message);
              
          }

          SetLastKnownLocation(locationManager.Location);
          
      }
开发者ID:JPHBrivo,项目名称:xamarin-plugins,代码行数:87,代码来源:GeofenceImplementation.cs

示例11: AvailableForMonitoring

      /// <summary>
      /// Checks if is available for monitoring
      /// </summary>
      /// <returns></returns>
      public bool AvailableForMonitoring()
      {
          bool retVal = false;
          RequestAlwaysAuthorization();
           
     
          if (!CLLocationManager.LocationServicesEnabled)
          {
              string message = string.Format("{0} - {1}", CrossGeofence.Id, "You need to enable Location Services");
              System.Diagnostics.Debug.WriteLine(message);
              CrossGeofence.GeofenceListener.OnError(message);
          }
          else if (CLLocationManager.Status == CLAuthorizationStatus.Denied || CLLocationManager.Status == CLAuthorizationStatus.Restricted)
          {
              string message = string.Format("{0} - {1}", CrossGeofence.Id, "You need to authorize Location Services");
              System.Diagnostics.Debug.WriteLine(message);
              CrossGeofence.GeofenceListener.OnError(message);

          }
          else if (CLLocationManager.IsMonitoringAvailable(typeof(CLRegion)))
          {
              if (RequestNotificationPermission)
              {
                  using (var pool = new NSAutoreleasePool())
                  {
                      pool.InvokeOnMainThread(() => {
                          var settings = UIUserNotificationSettings.GetSettingsForTypes(
                                             UIUserNotificationType.Alert
                                             | UIUserNotificationType.Badge
                                             | UIUserNotificationType.Sound,
                                             new NSSet());
                          UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                      });
                  }
              }
              retVal = true;
          }
          else
          {
              string message = string.Format("{0} - {1}", CrossGeofence.Id, "Not available for monitoring");
              System.Diagnostics.Debug.WriteLine(message);
              CrossGeofence.GeofenceListener.OnError(message);
          }

          

          return retVal;

      }
开发者ID:JPHBrivo,项目名称:xamarin-plugins,代码行数:53,代码来源:GeofenceImplementation.cs


注:本文中的NSAutoreleasePool.InvokeOnMainThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。