socc3rpr0
11 years agoOccasional Contributor
Event Handler(s)
Hello,
How would I go about creating an event handler that will cover all my bases such as window not recognize, engine failure, posting an error to the event log, etc...?
The problem I have is that is that I need to open a TCP connection with a device under test and need to run through all my scripts, but when they do fail I want to be able to close the TCP connection before the error is posted on the event log. This would allow me to establish the connection again when I restart my scripts. I have tried using a try, catch, finally, but this does not cover errors posted to the event log, and I want to be able to just handle anything that went wrong with one event handler..is it possible? If I don't close the connection after a test(s) fail or pass then next time around I want to rerun something the connection is still open therefore I can't establish connection with the device and have to remove the ethernet cable and reinsert it after each run.
this is what I have which assumes it will pass all critira on test, but we all know that won't happen all the time.....
function main()
{
EstablishConnection();
Test1();
Test2();
......
CloseConnection();
}
How would I go about creating an event handler that will cover all my bases such as window not recognize, engine failure, posting an error to the event log, etc...?
The problem I have is that is that I need to open a TCP connection with a device under test and need to run through all my scripts, but when they do fail I want to be able to close the TCP connection before the error is posted on the event log. This would allow me to establish the connection again when I restart my scripts. I have tried using a try, catch, finally, but this does not cover errors posted to the event log, and I want to be able to just handle anything that went wrong with one event handler..is it possible? If I don't close the connection after a test(s) fail or pass then next time around I want to rerun something the connection is still open therefore I can't establish connection with the device and have to remove the ethernet cable and reinsert it after each run.
this is what I have which assumes it will pass all critira on test, but we all know that won't happen all the time.....
function main()
{
EstablishConnection();
Test1();
Test2();
......
CloseConnection();
}