What if the delete method does not work?

Well, here I am again with another frustrating question. I need to finish my main process and restart it, but I cannot just finish the application gracefully ...

I use the C # application in combination with the patented (not for me) equipment for data collection, so right there it is getting complicated.

There is a scenario where my software works successfully, collecting its data, as it should, when the hardware with which I interact suddenly loses power and connection with my application. My application ultimately determines this, and I just need to get rid of my old connection and create a new one to reconnect to my equipment. Wrong...

Of course, the .Dispose () method for my object (an interface object with hardware), which terminates the connection, does nothing and actually just blocks forever when I try to start it. Apparently, there is some kind of connection that never works according to the dispose method, which requires the device to be connected when disconnected. I did not write a method, so I really do not know.

Finally, here is my question. The only way to start and run the application again is to close it and open it again. Of course, I cannot close it, because I cannot start the Dispose method. I am forced to end the process using the task manager. Yes, the process, not just the application. If I just close it, the process will remain alive forever, I have no choice.

, , ? , , ?

Application.Restart(), , , . , ? , - ? Application.Exit, , .

, , . , .

+5
3

, ? , , "", , , , . , "".

, , , - .

+9

, Dispose(), IDisposable, finalizer Dispose(), , GC.SupressFinalize(objWithFailingDispose), Dispose .

, .

+1

, , " , Dispose(), , ?" !

- , , GC.SuppressFinalize(internalConnectionObject);, , . , , , , . - , .

+1

All Articles