Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:25:10+00:00 2026-06-09T22:25:10+00:00

I’m using a LoadingView (custom UIAlertView with a UIActivityIndicatorView) to display different status. Here

  • 0

I’m using a LoadingView (custom UIAlertView with a UIActivityIndicatorView) to display different status.
Here is the LoadingView code:

public class LoadingView : UIAlertView
{
    private UIActivityIndicatorView _activityView; 

    public void Show (string title_)
    { 
        Title = title_;

        _activityView = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge); 
        _activityView.Frame = new System.Drawing.RectangleF (122, 50, 40, 40); 

        AddSubview (_activityView); 

        InvokeOnMainThread (delegate() { 
            _activityView.StartAnimating (); 
        });

        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; 

        Show ();
    }

    public void SetTitle (string title_)
    {
        Title = title_;
    }

    public void Hide ()
    { 
        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; 
        DismissWithClickedButtonIndex (0, true);
    }
}

I’m also using geolocalisation. For that, the user needs a network connection, carrier data or wifi network. So, my app’ needs to verify networks are available.

So, I add the Reachability class. I use the InternetConnectionStatus method:

public static NetworkStatus InternetConnectionStatus ()
{
    NetworkReachabilityFlags flags;
    bool defaultNetworkAvailable = IsNetworkAvailable (out flags);

    if (defaultNetworkAvailable) {
        if ((flags & NetworkReachabilityFlags.IsDirect) != 0) {
            return NetworkStatus.NotReachable;
        }
    } else if ((flags & NetworkReachabilityFlags.IsWWAN) != 0) {
        return NetworkStatus.ReachableViaCarrierDataNetwork;
    } else if (flags == 0) {
        return NetworkStatus.NotReachable;
    }
    return NetworkStatus.ReachableViaWiFiNetwork;
}

And I test it that way:

    partial void BtnLocationClick()
    {
        loading = new LoadingView();
        loading.Show("Looking for network");
        Console.WriteLine("Looking for network");
        if (Reachability.InternetConnectionStatus() != NetworkStatus.NotReachable)
        {
            loading.SetTitle("Network found");
            loading.Hide();
            // code here
        }
        else
        {
            loading.Hide();
            UIAlertView alert = new UIAlertView("Error", 
                                                "No network", 
                                                null, "Retour", null);
            alert.Show();
        }
    }

At the end, the network is quickly found (thanks to Console in InternetConnectionStatus method), but the LoadingView, declared before network detection and supposed to be shown is frozen.

When there is no network at all (no data and no wifi), it’s perfect. It displays correctly. But when I’ve some network, it freezes.
And then, after a long time, I can see “Network found” and things move on correctly.

I don’t understand at all what’s happening. Do you have any idea ?

Thanks in advance for the help you can provide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:25:12+00:00Added an answer on June 9, 2026 at 10:25 pm

    You are doing this work and blocking the UI thread.

    Let’s say you did this:

    loading.Show();
    Thread.Sleep(1000);
    loading.Hide();
    

    You would never see the loading, since the UI thread is blocked and unable to render your loading popup.

    You will have to use the .Net threading classes to do something like this:

    loading.Show();
    ThreadPool.QueueUserWorkItem(_ =>
    {
       //Do your long running operation here
    
       BeginInvokeOnMainThread(() => loading.Hide());
    });
    

    The BeginInvoke part is very important. You cannot interact with the UI from a background thread, this invokes your code back on the main thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.