Sachin Kothari
Sachin Kothari

Reputation: 31

Need to create a timer of 5 mins in Silverlight

I'm a newbie to Silverlight.

Recently i downloaded a solution which records an Audio from the webpage present under silvoicerecordupload.codeplex.com/

What i'm trying to do is, The recording should stop after 5 mins.

I found some articles like:

Dispatcher class

Timer class

I tried using the Dispatcher class, it just has Start() and Stop() methods, but i cannot keep track of time that is being spent on the recording.

Please help me regarding this.

Thanks, Sachin

Upvotes: 0

Views: 62

Answers (1)

Martin
Martin

Reputation: 6146

I haven't checked the codeplex project but I'm assuming you have means of starting and stopping the recording via two methods. The timer will call the StopRecording() method as soon as the time specified by recordingTimeInMilis is used up.

public class TimedRecorder
{
    private const int recordingTimeInMilis = 5 * 60 * 1000;
    private Timer m_timer;
    public void StartRecording()
    {
        m_recorder.Start();
        m_timer = new Timer(
            StopRecording, null, recordingTimeInMilis, Timeout.Infinite);
    }
    public void StopRecording()
    {
        m_recorder.Stop();
        m_timer.Dispose();
        m_timer = null;
    }
}

Upvotes: 1

Related Questions