I have a class defined as follows, the Stop() function just wants to see whether the data is saved or not. If it's saved, then it deletes the data, otherwise, it starts a new thread to save the data (because the data might be very big, and costs much time to save). I wonder whether it's a good practice to start a new thread like this. If exception happens in the thread, how could I handle it? If the save takes a long time, what will happen if the user close the application? It doesn't seem to be a good practice for me, but I don't know whether I'm correct. If it's not good, what could be a better way to do it? Thanks!
public class AHelperClass
{
public void Stop()
{
if (IsDataSaved)
{
DeleteData();
}
else
{
Thread aThread = new Thread(() => SaveData());
aThread.Name = "Saving Thread";
aThread.Start();
}
}
}