C
Craig Lister
I am having unexpected results with a Try/Catch. The method simply
recieves a string, and sends it to a ComPort. I am testing the
scenario of a lost connection.
So, I call this method...
public string WriteData(string msg, bool requireReply)
{
_comPort.DiscardInBuffer();
_comPort.WriteLine(msg);
if (requireReply)
{
try
{
return _comPort.ReadLine();
}
catch (TimeoutException toe)
{
throw;
}
}
return string.Empty;
}
My calling code is surrounded by a Try/Catch(TimeoutException toe).
However, when I run this code... the application breaks out and shows
me that the was an unhandled timeout exception.
What am I doing wrong? I excpect it to throw it to the calling code,
and handle it there.
recieves a string, and sends it to a ComPort. I am testing the
scenario of a lost connection.
So, I call this method...
public string WriteData(string msg, bool requireReply)
{
_comPort.DiscardInBuffer();
_comPort.WriteLine(msg);
if (requireReply)
{
try
{
return _comPort.ReadLine();
}
catch (TimeoutException toe)
{
throw;
}
}
return string.Empty;
}
My calling code is surrounded by a Try/Catch(TimeoutException toe).
However, when I run this code... the application breaks out and shows
me that the was an unhandled timeout exception.
What am I doing wrong? I excpect it to throw it to the calling code,
and handle it there.