5

I have a program up and going that interacts with hardware, but I need to test the case of when the program crashes/aborts or anything to cause the program to exit unnormally to see what state is set to the hardware when the software crashes.

In C++ I saw a post about using an abort() call (What is the easiest way to make a C++ program crash?), but I am unsure what the VB equivalent of that would be. The closest I have come is while debugging, to press the Stop Debugging button, but I think there is a better solution than that.

Is there any specific code that would cause this type of event to happen or is there a call like abort() that would make it happen in a heartbeat?

Community
  • 1
  • 1
StevenTsooo
  • 498
  • 4
  • 13
  • No idea if this is relevant to your situation but you might also want to look at the Application Events UnhandledException handler - you could maybe use this as a backstop to respond to (nearly) any exception and force the hardware into a known safe state. – peterG Aug 06 '13 at 13:57

1 Answers1

6

Use the API Environment.FailFast. This is a .Net API accessible from any managed language including VB.Net. It will ruthlessly terminate the current process

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454