how to temporailty block process death

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a C# app that is doing a series of coordinated disk writes. I want to
prevent or postpone the death of my process by the user while I am in the
middle of this sequence. Can I do this?
 
I have a C# app that is doing a series of coordinated disk writes. I want
to
prevent or postpone the death of my process by the user while I am in the
middle of this sequence. Can I do this?

Death by "task manager" isn't possible (if that's what you mean).
 
really! That surprising and disappointing. How do database engines work on
windows then? I suppose by writing an undo log, flushing it and then doing
the writes and rolling back on restart it not cleanly shutdown

In other OS I just arrange to catch the kill signal
 
really! That surprising and disappointing. How do database engines work on
windows then? I suppose by writing an undo log, flushing it and then doing
the writes and rolling back on restart it not cleanly shutdown

In other OS I just arrange to catch the kill signal

Well think about it. What if a process doesn't respond to the "kill signal"
in a timely manner if at all. Should the user or OS itself now be at the
mercy of some program that won't shut down. I find it very difficult to
believe that any OS on the planet doesn't have a similar mechanism (forced
terminatiion of an app to be used as a last resort only). As for your DB
question, what will your app do if the power goes off in the middle of a
write. Transaction processing is the answer to both these scenarios. You
might also find the following informative (see "TerminateProcess()" in
particular)

http://support.microsoft.com/kb/178893
http://msdn2.microsoft.com/en-us/library/ms686714.aspx
 
Hello Paul,
I have a C# app that is doing a series of coordinated disk writes. I want
to
prevent or postpone the death of my process by the user while I am in the
middle of this sequence. Can I do this?

Like Larry already mentioned, you cannot postpone or disable killing of your
application; if that would be possible, think about all malicious
applications like viruses, how could you ever get rid of them if killing
wouldn't work?

Now then, regarding your question about coordinated or atomic disk writes.
Currently, most database applications use the concept of transactions, which
are most often implemented using a log file and the actual database file.
When data is written to the database, it goes to the log file first (1).
Then, upon commit it is written to the database (2), and finally the log
file is cleared (3). The system is built so that it can later on detect, if
for example the system crashes between 2 and 3, for instance because of a
power failure.

Finally, an idea to your solution. Unless you want to start using SQL
databases or write your own log file/transaction support, I suggest taking a
look at Transactional NTFS (TxF), which is a new feature in Windows Vista ja
forthcoming Windows Server 2008:

http://msdn2.microsoft.com/en-us/library/aa365456.aspx

This feature would be exactly what you are looking for: transactions on the
NTFS file system. Works like a charm.

Good luck!

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
(e-mail address removed)
http://www.saunalahti.fi/janij/
 
Back
Top