I have a window form that usually starts as a scheduled task, so I thought I would pass the arguments to the command in the task so that it starts automatically. That way, I could start it locally with no arguments, to manually start it if necessary. But I'm not quite sure how to get it to call a new form method after calling Application.Run when it starts as a task. Right now, it just shows the form and goes there, and then goes to the i.RunImport () line. Any ideas? Here is my code. Thank.
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0)
{
if (args.Any(x => x == "run=1"))
{
var i = new Importer();
Application.Run(i);
i.RunImport();
}
}
else
{
Application.Run(new Importer());
}
}
source
share