MonoMobile.Views.ProgressHud.ShowWhileAsync C# (CSharp) Method

ShowWhileAsync() public method

public ShowWhileAsync ( System.Action execute, bool animated ) : Action
execute System.Action
animated bool
return Action
		public Action<ActionResult> ShowWhileAsync(Action execute, bool animated)
		{
			// Launch execution in new thread
			_TaskInProgress = true;
			
			// Show HUD view
			Show(animated);

			var thread = new System.Threading.Thread(() =>
			{
				using (NSAutoreleasePool pool = new NSAutoreleasePool())
				{
					execute();
				}
			});
				
			thread.Start();
			
			return (result) => Completed();
		}

Usage Example

            public override void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath indexPath)
            {
                if (ProgressButtonData.IndicatorStyle == IndicatorStyle.Hud)
                {
                    var progress = new ProgressHud()
                    {
                        TitleText       = ProgressButtonData.Title,
                        DetailText      = ProgressButtonData.DetailText,
                        MinimumShowTime = ProgressButtonData.MinimumShowTime,
                        GraceTime       = ProgressButtonData.GraceTime
                    };

                    Action asyncCompleted = null;

                    asyncCompleted = progress.ShowWhileAsync(() =>
                    {
                        if (DataContext != null)
                        {
                            InvokeOnMainThread(() =>
                            {
                                ExecuteMethod(asyncCompleted);
                            });
                        }
                    }, true);
                }
                else
                {
                    base.Selected(controller, tableView, item, indexPath);
                }

                tableView.DeselectRow(indexPath, true);
            }
All Usage Examples Of MonoMobile.Views.ProgressHud::ShowWhileAsync