P
Paul
Hi,
In my application I have a separate DLL which handles encrypting data
in the application (including saving it to disk, and loading it).
The main application calls for example "EncryptToDisk(object obj,
string fileName)".
This method then opens a new form (internal to the DLL assembly) with
a progress bar on it which is updated to show how things are going.
In order for the new form be displayed and update correctly I had to
put it on it's own thread, otherwise the Encrypt function would take
all the CPU time from the form.
This is all working fine.
However when the progress bar form is open I want it to block the
Windows shutdown, because shutting down during this period will cause
the data to be lost.
The process only takes a few seconds, but as soon as it receives the
command to shutdown from windows, it kills everything.
I tried adding the following to the new form:
protected override void WndProc(ref Message aMessage)
{
const int WM_QUERYENDSESSION = 0x0011;
const int WM_ENDSESSION = 0x0016;
if (aMessage.Msg == WM_QUERYENDSESSION || aMessage.Msg ==
WM_ENDSESSION)
return;
base.WndProc(ref aMessage);
}
This doesn't do anything though, I can see WndProc is passing other
messages through (I can't debug the endsession messages), but the form
and application are still killed.
In my application I have a separate DLL which handles encrypting data
in the application (including saving it to disk, and loading it).
The main application calls for example "EncryptToDisk(object obj,
string fileName)".
This method then opens a new form (internal to the DLL assembly) with
a progress bar on it which is updated to show how things are going.
In order for the new form be displayed and update correctly I had to
put it on it's own thread, otherwise the Encrypt function would take
all the CPU time from the form.
This is all working fine.
However when the progress bar form is open I want it to block the
Windows shutdown, because shutting down during this period will cause
the data to be lost.
The process only takes a few seconds, but as soon as it receives the
command to shutdown from windows, it kills everything.
I tried adding the following to the new form:
protected override void WndProc(ref Message aMessage)
{
const int WM_QUERYENDSESSION = 0x0011;
const int WM_ENDSESSION = 0x0016;
if (aMessage.Msg == WM_QUERYENDSESSION || aMessage.Msg ==
WM_ENDSESSION)
return;
base.WndProc(ref aMessage);
}
This doesn't do anything though, I can see WndProc is passing other
messages through (I can't debug the endsession messages), but the form
and application are still killed.