Application exit even not firing in c# windows application
<p>I am using the below class to hide and show the windows task bar.
I am calling the the class like below.</p>

<p>Problem : when i start the application, the taskbar is hiding perfectly.
But when i exit the application by stopping the debugging, the task bar is 
not showing up. I mean the application exit is not firing in my code.
I need such a way like, whatever the way i close my application, it shud 
finially show the tashbar() before exiting.</p>

<p>Please help. Thanks.</p>

<p>PROGRAM :
<hr /></p>

<pre><code>static class Program
{

    [STAThread]
    static void Main()
    {
        Taskbar.Hide();
        Form1 TargerForm = new Form1();
        Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
        Application.EnableVisualStyles();
        Application.Run(TargerForm);
    }
    static void Application_ApplicationExit(object sender, EventArgs e)
    {
        Taskbar.Show();
    }
}
</code></pre>

<p>CLASS :
<hr /></p>

<pre><code>public class Taskbar
{
    [DllImport("user32.dll")]
    public static extern int FindWindow(string className, string windowText);
    [DllImport("user32.dll")]
    public static extern int ShowWindow(int hwnd, int command);

    public const int SW_HIDE = 0;
    public const int SW_SHOW = 1;

    public int _taskbarHandle;
    protected static int Handle
    {
        get
        {
            return FindWindow("Shell_TrayWnd", "");
        }
    }

    public Taskbar()
    {
        _taskbarHandle = FindWindow("Shell_TrayWnd", "");
    }

    public static void Show()
    {
        ShowWindow(Handle, SW_SHOW);
    }

    public static void Hide()
    {
        ShowWindow(Handle, SW_HIDE);
    }
}
</code></pre>
