JIM.H. <(E-Mail Removed)> wrote:
[snip]
> And I am running my application under windows task scheduler although it
> passes through Application.Exit(), the applications does not end. What might
> the problem be?
You haven't provided enough information. A complete, compiling snippet
would be best. For example:
---8<---
using System;
using System.Windows.Forms;
class App
{
[STAThread()]
static void Main(string[] args)
{
bool isPar = false;
if ((args.Length == 1))
{
if ((args[0].ToUpper() == "MYPAR"))
{
isPar = true;
}
}
if (isPar == true)
{
Form myForm = new Form();
AppStartUp(true);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form());
}
}
static void AppStartUp(bool cmSwitch)
{
Application.Exit();
}
}
--->8---
This application, based on the source code you supplied, exits in both
cases (whether MYPAR was passed or not).
Note that Application.Run() starts a message loop, and doesn't return
until the message loop has terminated. Application.Exit() ultimately
causes this message loop to return, after giving all forms a chance to
close. If you need the application to quit *immediately*, without
notifying any forms of closing etc, you can call Environment.Exit().
-- Barry
--
http://barrkel.blogspot.com/