I want to use a timer in my C# monodroid program for android 2.2, but it doesnt work. here is my code:
using System;
using System.Timers;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Util;
namespace MonoAndroidApplication1
{
[Activity(Label = "MonoAndroidApplication1", MainLauncher = true, Icon=drawable/icon")]
public class Activity1 : Activity
{
int count = 1;
TextView txv1;
System.Timers.Timer t1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
txv1 = FindViewById<TextView>(Resource.Id.txv1);
DateTime dt = DateTime.Now;
txv1.Text = dt.ToShortTimeString();
t1 = new System.Timers.Timer(200);
t1.Elapsed += new ElapsedEventHandler(OnTimeEvent);
t1.Interval = 200;
t1.Enabled = true;
t1.Start();
}
private void OnTimeEvent(object source, ElapsedEventArgs e)
{
txv1.Text = count.ToString();
count++;
}
}
}
please help me.