I have an Activity which runs a number of separate downloading tasks on different threads. They are creating in onCreate() like this:
public override void OnCreate()
{
base.OnCreate();
workerThread = new Thread(() =>
{
InitialiseDownloads();
foreach (DownloadingFile file in downloadingFiles)
{
Thread t = new Thread(file.StartDownload);
threads.Add(t);
t.Start();
}
});
workerThread.Start();
}
Where a List<Thread>
threads is filled with a new thread for every file to download.
If the activity is closed before these threads finish, will they keep running after the activity is killed if I don't abort them? If so, is this appropriate:
public override void OnDestroy()
{
workerThread.Abort();
foreach (Thread thread in threads)
{
thread.Abort();
}
base.OnDestroy();
}