System.Timers.Timer turns app very slow and sometimes freezing

Hi there,
Since last update of Xamarin.Android the System.Timers.Timer start working very strangely. This code take at least to 5 seconds to trigger Elapsed. When it need to bre one second (The interval time).

                        Monitor = new Timer ();
            Monitor.AutoReset = true;
            Monitor.Interval = 1000;
            Monitor.Elapsed += (object sender, ElapsedEventArgs e) => {
                        //After 5 second this are fired
                RunOnUiThread (() => {
                    TimeElapsed++;
                    Time.Text = TimeElapsed.ToString ();
                });
                        //Arround 5 loops later the UI sometimes freezes
            };

            addTaskButton.Click += (sender, e) => {
                Monitor.Start ();
            };

And when the Timer is running sometimes the UI freezes, making slugish expirience.

This code was working perfectly until this last update.
Curiosly, I have another app using Threads for background tasks, this Tasks takes more than usually to start (2-3 seconds aprox).
In the two cases, nothing additionally is running on UI thread.

Answers

  • Nicolas77Nicolas77 CHMember ✭✭
    edited May 2015

    I am also experiencing similar issues with System.Timers or System.Threading.Timer. Since the last update, the app sometimes freezes when using timers. Did you find something to solve your issue?

Sign In or Register to comment.