Start New Discussion within our Software Development Community

Heading Here

I have a button
when i press it the following event starts
that records from the microphone
I want the while loop to stop after a certain time so i added a tick event
from what i know after stating the tick is should take one tick ( 50 milisec in this case)
to trigger the event
but nothing happens and i am stuck in an endless loop
this is the code:

 public void StartRecording()
            DispatcherTimer dt = new DispatcherTimer();
            dt.Interval = TimeSpan.FromMilliseconds(50);
            dt.Tick += new EventHandler(dt_Tick);
            if (microphone == null)
                microphone = Microphone.Default;
                microphone.BufferDuration = TimeSpan.FromMilliseconds(1000);

                buffer = new byte[microphone.GetSampleSizeInBytes(
                var _sampleRate = microphone.SampleRate;
             _stopRequested = false;

            if (dt.IsEnabled == false)

            while (_stopRequested == false)
                Buf_total_len = +buffer.Length;
        private void dt_Tick(object sender, EventArgs e)

            _stopRequested = true;

I sould add it is a silverlight applcation using xna framework and using FrameworkDispatcher.Update() did not help

This article has been dead for over six months. Start a new discussion instead.