Forum Xamarin.iOS

NSProgessIndicator Binding "Hidden" Property Latency Problem

AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

I have a ProgressBar and a ProgressRing whose "Hidden" property is bound to an exported public "Discovering" property. Unhiding them is not a problem. But when I set the property to re-hide them, it takes a quite long time for the binding to take effect. The latency time is variable and can be as long as a minute. Even setting the "Display When Stopped" has no effect.

I've attached a test project and in it, I have a test Label which is bound to the same property and it does not exhibit the same latency problem.

Is this a known issue and if so, will it be fixed and is there a work-around?

Thanks

Posts

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    This is not a Xamarin.Mac bug.

    In your example, you have this:

        void Timer_Tick(object obj, EventArgs args)
        {
            Console.WriteLine("Got a tick = " + _tick++);
    
            if (_tick >= 5)
            {
                _timer.Stop();
                Discovering = false;
    
                BeginInvokeOnMainThread(() =>
                {
                    Console.WriteLine("About to stop animation.");
    

    Note that you are setting Discovering on the timer thread. This means you are setting WillChangeValue / DidChangeValue on the timer thread.

    This is bad. You should not do anything UI related on the non-UI thread unless you clear it by the documentation (https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html).

    Moving that into the BeginInvokeOnMainThread call made things work for me. I'm surprised that poking UI bits on the non-ui thread didn't crash/mess things up more.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭
    edited January 2017

    That IS interesting that it didn't crash. But what's even more interesting is that the progress controls DID eventually hide AND the NSTextField hid immediately.

    Thanks Chris. I'll try not to make that mistake again:).

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Likely there is an update every minutes on Cocoa's end that happened to notice the variable was changed and your will/did were flat out ignored.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    But no problem at all with the NSTextField. :/

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    It doesn't really matter whether it worked for some controls and not others. What matters is the correct way to do it is as @ChrisHamons described. No need for speculation.

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    The "correct" way is always the "best" way.

Sign In or Register to comment.