Unable to shut down machine when a .net application is running

  • Thread starter Thread starter kuldeep
  • Start date Start date
K

kuldeep

Hi all,

I have a application developed in C# .net. The problem I face is I am unable
to shutdown my machine
when the exe is running. Windows is unable to close this exe an shut down.
Can anyone help.


Regards,
Kuldeep Pawar
Programmer,
Maximize Learning, Pune.
www.maximizelearning.com
 
* "kuldeep said:
I have a application developed in C# .net. The problem I face is I am unable
to shutdown my machine
when the exe is running. Windows is unable to close this exe an shut down.
Can anyone help.

Without knowing what the executable is actually doing, an answer is
impossible. Does that even occur with a new project (blank
application)?
 
Hi ,

My application is on tray mode when the form closing button is pressed.

class MyForm : Form
{
private System.Windows.Forms.NotifyIcon_notifyIcon;
private void MyForm_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Visible = false;
}
}



This might force the system not to shutdown.
When system is shutting down, the MyForm_Closing() is called, not
Application.Exit();
So, my application is just on tray mode and, the shutdown process is
stopped.


How to shutdown the application either when I am logging off or shutting
down the machine? I tried by handling the WM_QUERYENDSESSION messagewhere I
set a flag which indicates that call is for shutdown of machine and made
changes in the closing event handler as shown below but its not working.
private System.Windows.Forms.NotifyIcon_notifyIcon;
private void MyForm_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{ if(systemShutdown) {
e.Cancel = false;
} else { e.Cancel = true;
this.Visible = false; }
}
 
Back
Top