I have a windows service which runs unmanaged code (using DllImport) in different threads.
Sometimes, the unmanaged code 'hangs'. Think of while (true) ;. When that happens, I need to kill the entire process (which automatically starts another because it's a windows service).
Is Environment.Exit(int) sufficient? Or will I need e.g. Environment.FailFast(string)?
Edit: I am unable to 'test' this. The freezes happen randomly.
From the official Microsoft documentation,
Environment.Exit:More usefully, the documentation goes on to state:
It sounds like
Environment.Exitis perfectly sufficient for your needs.