Xamarin ios UItableView Empty rows at top using Task Scheduler in background

I have one empty row in the top when I load uitableview object inside UIApplication.SharedApplication.BeginInvokeOnMainThread(() but it works fine (no empty row)without using TaskFactory.

Anyone has any idea ? Thanks for your time and help.

var bounds = UIScreen.MainScreen.Bounds;
// show the loading overlay on the UI thread using the correct orientation sizing
loadingOverlay = new LoadingView(bounds, "Loading data...");
View.Add(loadingOverlay);

        var task = Task.Factory.StartNew(() =>
        {
            if (item == this.tabBarPendingBarItem)
            {
                if (isrefresh || ApprovalPendingList.Count == 0)
                {
                    ApprovalPendingList = CommonWebServices.GetPurchaseOrders(AppDelegate.SysproID);
                    ApprovalPendingListClone = new List<Approval>(ApprovalPendingList);
                }
            }

        }).ContinueWith((result) =>
        {
            try
            {
                UIApplication.SharedApplication.BeginInvokeOnMainThread(() =>//UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {

                        tableViewApprovalList.Source = new TablePurchaseOrderPendingListSource(ApprovalPendingList);         
        Add(tableViewApprovalList);
        tableViewApprovalList.ReloadData(); 
        tableViewApprovalList.SizeToFit(); 
                        UICommon.SetHeaderColor(this.NavigationController, this.NavigationItem, "Pending Orders");

                    if (loadingOverlay != null)
                        loadingOverlay.Hide();
                });
                //);
            }
            catch (Exception exp)
            {

                //  throw;
            }
        });
Tagged:
Sign In or Register to comment.