EDN Admin
Well-known member
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri Hi All
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri Please tell me is it possible to block windows shutdown from my windows service application until I finished my VERY IMPORTAN job and shutdown
after that.
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri I managed to do it for Windows server 2003 if Service interact with the desktop, the hidden form is created and if the VERY IMPORTANT job
is executed it blocks windows shutdown as reject closing of my hidden form.
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri The problem is Windows server 2008, because it not work for FormClosing() event when property Cancel =true;
<span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri
<pre>protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_QUERYENDSESSION)
{
systemShutdown = true;
}
base.WndProc(ref m);
}
private void HiddenForm_FormClosing(object sender, FormClosingEventArgs e)
{
//ignore form closeing
if (systemShutdown)
{
systemShutdown = false;
e.Cancel = true;
}
else
e.Cancel = false;
}[/code]
View the full article
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri Please tell me is it possible to block windows shutdown from my windows service application until I finished my VERY IMPORTAN job and shutdown
after that.
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri I managed to do it for Windows server 2003 if Service interact with the desktop, the hidden form is created and if the VERY IMPORTANT job
is executed it blocks windows shutdown as reject closing of my hidden form.
<p style="margin:0cm 0cm 0pt <span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri The problem is Windows server 2008, because it not work for FormClosing() event when property Cancel =true;
<span lang="EN-US" style=" <span style="font-size:small <span style="font-family:Calibri
<pre>protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_QUERYENDSESSION)
{
systemShutdown = true;
}
base.WndProc(ref m);
}
private void HiddenForm_FormClosing(object sender, FormClosingEventArgs e)
{
//ignore form closeing
if (systemShutdown)
{
systemShutdown = false;
e.Cancel = true;
}
else
e.Cancel = false;
}[/code]
View the full article