Application doesn't execute Form1_load method when started by Scheduled Task
<p>I have an App in C# using Windows Forms. My application is working normally, but when I want to start it by OS (Windows 7) using Scheduled Task, it doesn't load Form1_load method. How could I solve this problem?</p>

<p>Here is a body of Form1_load method:</p>

<pre><code> private void   Form1_Load(object sender, EventArgs e)
    {
        try
        {

            bool fResult = false;
            fResult = registerDeviceNotification();
            g_oGeneratorManager = new CGeneratorManager();
            if (true != fResult)
            {
                Debug.WriteLine("Register device notification failed");
                MessageBox.Show("Register device notification failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lblStatus.Text = "Running";
        }
        catch (Exception ex)
        {
            this.Visible = false;
            CLog.Err(ex.Message);
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Application.Exit();
        }
    }
</code></pre>
