Device.StartTimer doesn't stop

WayneRichmondWayneRichmond GBMember
edited March 2015 in Xamarin.Forms

It appears I may have the problem of it not deploying the updated code to the iPAD. I have seen this before.

Hi,
I have the following code snippet in the .cs of my xaml page.

  public ConectingXamlPage()
    {
        InitializeComponent();

        DependencyService.Get<INetScan>().NetScan();

        Device.StartTimer(TimeSpan.FromSeconds(1), () =>
        {
            if (DependencyService.Get<INetScan>().Connected)
            {
                TestXamlPage tp = new TestXamlPage();
                Navigation.PushAsync(tp);
                return false;
            }
            if (DependencyService.Get<INetScan>().ScanFinished)
            {
                DependencyService.Get<INetScan>().StartScan();
            }
            return true;
        });
    }

Before I added the return false to the above code this worked fine on Android as sool as I tried it on iOS the timer did not stop so I added the return false.
It still doesnt stop in iOS.
The code appears to step over the return false when debugging (I am using VS2013 with a mac build) but it keeps going and the second page just keeps initialising.

Any ideas ?

I have seen a few posts regarding the StartTimer but nothing like this.

Wayne

Posts

  • WayneRichmondWayneRichmond GBMember

    OK. I have sorted it.
    I forgot that when you have the iOS build as startup project and hit the run button in VS2013 it doesn't build the updated PCL code. So you need to build that separately before running it.

    The second thing is that Android appears to stop the timer when you navigate away from the page but iOS doesn't. I should have the manual stop in there anyway (return false) but just an observation.

    Wayne

Sign In or Register to comment.