I have a small app that a client uses to manually update some data. It is very basic; on load it populates a list of companies the user can select from and click a button to update the data in another system. The client wants to be able to run this same functionality from command line so I have added a background worker. When the app is launched, I check for a specific arg and if found I kick off the worker. Once the worker completes I call Close();
This all seems to work fine (the data gets updated as expected and the app appears to close), but when I check task manager the app is still running.
My questions:
- What thing/things should I be looking for to find the cause of the app still running?
- Is there a better way to do this?
Here's a sample of the code:
public MainForm()
{
InitializeComponent();
var args = Environment.GetCommandLineArgs();
Array.ForEach(args, x => x.ToLower());
if (args.Contains("u"))
backgroundWorker.RunWorkerAsync();
}
private void BackgroundWorkerDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
//call to web service to update data
}
private void BackgroundWorkerRunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
Close();
}