Bug 28953 - Device.StartTimer (still) behaves differently on different platforms
Summary: Device.StartTimer (still) behaves differently on different platforms
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-04-09 17:24 UTC by Adam Kemp
Modified: 2017-01-30 16:43 UTC (History)
8 users (show)

Tags: functional consistancy ac
Is this bug a regression?: ---
Last known good build:

Test case (176.04 KB, application/zip)
2015-04-09 17:24 UTC, Adam Kemp

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Adam Kemp 2015-04-09 17:24:10 UTC
Created attachment 10695 [details]
Test case

On Android you can call Device.StartTimer from any thread. On iOS you have to call it from the UI thread. Who knows what happens on Windows Phone. These all need to do the same thing. The behavior should be that you can start a timer from any thread, and the callback runs on the UI thread. On iOS it should use NSTimer (it does). On Android it should use a Handler (it does not). On Windows Phone it should use a DispatcherTimer (I don't know whether it does). Under no circumstances should any platform use System.Threading.Timer, which should probably be banned from your codebase.

To reproduce the issue run the attached project. On Android you see a counter. On iOS you just see the stock Xamarin.Forms welcome message.
Comment 1 Abhishek 2015-04-28 13:27:07 UTC
I have tried this issue and able to reproduce the reported behavior at my end.

Steps To Reproduce:
1. Download the attached sample.
2. Update the xamarin.forms package of the application.
3. Run the application on Emulator/Android Device.It will show the timer count.
4. Run the application on Simulator/Device.It will show the welcome page of the Xamarin.Forms.

Screencast: http://www.screencast.com/t/vkn0BUcuF
IDE Log: https://gist.github.com/Abhishekk360/e1601fe67fd1e4c8f6c5
Android Device Log: https://gist.github.com/Abhishekk360/88f52fe93a713027bfb6
iOS Device Log:https://gist.github.com/Abhishekk360/b0bdd3282497900dc08c

Environment Info:

=== Xamarin Studio ===

Version 5.9 (build 436)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
	Mono 4.0.1 ((detached/735f5b3)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000008

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 62f9f08
Branch: master
Build date: 2015-04-27 22:39:33-0400

=== Xamarin.Android ===

Version: (Enterprise Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Enterprise Edition)

=== Build Information ===

Release ID: 509000436
Git revision: 7e8ba4cbccf7b188ce5e80a90fdc4acdedb5a83f
Build date: 2015-04-23 13:19:57-04
Xamarin addins: 21fd95f743742c5237e22023996c2800ce3f8db3

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Chris King 2015-05-27 16:25:44 UTC
Indeed, counter is not update on iOS.
Comment 3 adrianknight89 2016-09-23 22:28:31 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/374
Comment 4 Samantha Houts [MSFT] 2017-01-12 18:06:46 UTC
Should be fixed in 2.3.4-pre2. Thank you!
Comment 5 Parmendra Kumar 2017-01-30 16:43:01 UTC
I have checked this issue with Xamarin.Forms and observed that this issue has been fixed. on iOS timer count shows successfully.