private void CleanUpAfterPressTooShort()
{
// Seems sometimes on a very short click the recording actually got started while we were informing the user
// that he didn't click long enough. Before we try to delete the file where the recording is taking place,
// we have to stop it; otherwise, we will get an exception trying to delete it.
while (Recording)
{
try
{
#if __MonoCS__
#else
Recorder.Stop();
#endif
Application.DoEvents();
}
catch (Exception)
{
}
}
// Don't kid the user we have a recording for this.
// Also, the absence of the file is how the UI knows to switch back to the state where 'speak'
// is the expected action.
try
{
RobustFile.Delete(PathToCurrentAudioSegment);
}
catch (Exception error)
{
Logger.WriteError("Audio Recording trying to delete "+PathToCurrentAudioSegment, error);
Debug.Fail("can't delete the recording even after we stopped:"+error.Message);
}
// If we had a prior recording, restore it...button press may have been a mistake.
if (RobustFile.Exists(_backupPath))
{
try
{
RobustFile.Copy(_backupPath, PathToCurrentAudioSegment, true);
}
catch (IOException e)
{
Logger.WriteError("Audio Recording could not restore backup " + _backupPath, e);
// if we can't restore it we can't. Review: are there other exception types we should ignore? Should we bother the user?
}
}
}