G
Guest
Application - give Oracle DB connection status on an ongoing basis
Technique--thread is fired off by a timer every minute. It attempts to open
a connection. It catches an open error as a failure, and otherwise indicates
success. It then disposes the connection and ends.
The status indicated seems to be good the first time. However,
subsequently, it seems to get stuck in the old status, and doesn't always see
the connection as transitioning to good from bad or vice-versa.
Here's a snippet ---
private void testDev(Object state)
{
try
{
oracleConnection1.Open();
oracleConnection1.Dispose();
devStatus.ForeColor = Color.Green;
devStatus.Text = "DEV UP";
devErrorTxt.Text = "";
}
catch (Exception e)
{
errorMsg = e.Message.ToString();
try
{
oracleConnection1.Dispose();
}
catch (Exception e2)
{
errorMsg += (" Dispose: " + e2.Message.ToString());
}
devErrorTxt.Text = errorMsg;
failureMode = true;
devStatus.ForeColor = Color.Red;
devStatus.Text = "DEV DOWN";
}
TimerCallback timerDelegate = new TimerCallback(testDev);
t = new System.Threading.Timer(timerDelegate,null,60000,-1);
}
Suggestions??
Technique--thread is fired off by a timer every minute. It attempts to open
a connection. It catches an open error as a failure, and otherwise indicates
success. It then disposes the connection and ends.
The status indicated seems to be good the first time. However,
subsequently, it seems to get stuck in the old status, and doesn't always see
the connection as transitioning to good from bad or vice-versa.
Here's a snippet ---
private void testDev(Object state)
{
try
{
oracleConnection1.Open();
oracleConnection1.Dispose();
devStatus.ForeColor = Color.Green;
devStatus.Text = "DEV UP";
devErrorTxt.Text = "";
}
catch (Exception e)
{
errorMsg = e.Message.ToString();
try
{
oracleConnection1.Dispose();
}
catch (Exception e2)
{
errorMsg += (" Dispose: " + e2.Message.ToString());
}
devErrorTxt.Text = errorMsg;
failureMode = true;
devStatus.ForeColor = Color.Red;
devStatus.Text = "DEV DOWN";
}
TimerCallback timerDelegate = new TimerCallback(testDev);
t = new System.Threading.Timer(timerDelegate,null,60000,-1);
}
Suggestions??