Q:

Timer does not get reset [Xamarin forms iOS] C#

I am currently working a function that gathers text and puts it together to a complete sentence. Once the sentence is complete I want to send the formatted text to a prepared function. 
What I have done to achieve this is to create a timer so when something is not getting sent within 5 seconds, I want the event with the gathered text to fire.
However, with my current code the timer never gets reset and the event gets fired after 5 seconds even though text was sent in during this time period which would reset the timer.
So this is the function that gets called when new text gets entered:
string result = "";
Timer time;
public void beginTimer(string text)
{ 
   result = result + " " + text;
   time.Stop();
   time = new Timer(5000); 
   time.Enabled = true;
   time.AutoReset = false;
   time.Start();
   time.Elapsed += new ElapsedEventHandler(timer_Elapsed);
}

And once the event fires I send the complete text to my other function:
public event EventHandler<EventArgsSentence> textChanged;

private async void timer_Elapsed(object sender, ElapsedEventArgs e)
{
    time = (Timer)sender;
    time.Stop();
    time.Enabled = false;

    textChanged.Invoke(this, new EventArgsSentence(result));
    result = "";
}

But with this code the timer does not get reset and the event always fires after 5 seconds even though beginTimer is being called during this timeperiod.

A:

Try this for stop timer 
time.Invalidate ();
time.Dispose ();
time = null;

