Link to home
Start Free TrialLog in
Avatar of g_johnson
g_johnsonFlag for United States of America

asked on

Application won't close ...

The code below comes from an application that currently runs just like any other Windows program.  It's written in C#, VS 2008, for the .Net 2.0 framework.

I need to add functionality such that if it is started with a command line argument, it is run unattended, i.e., it is not visible, goes directly to the method normally called by a click on a button, then shuts down.

I can't get it to shut down.  When I put Application.Exit(); after this.ReportProduction(); it still does not shut down.

What should I do?
public frmMain(string [] args)
        {
 
            InitializeComponent();
 
            if (args.Length != 0)
            {
                //running from scheduler
                this.btnNow.Visible = false;
                this.Opacity = 0;
                this.ShowInTaskbar = false;
                //every place that statlab or statlab2 is referenced while reporting production
                //  is inapproriate if unattended, and need to write to a log file instead
                this._Unattended = true;
                this.ReportProduction();
            }
        }

Open in new window

Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Hard to say without seeing the rest of the code.  You must have a thread still running
ASKER CERTIFIED SOLUTION
Avatar of Nate Feinberg
Nate Feinberg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of g_johnson

ASKER

Thanks -- kill worked