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)
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;