ArchiveFiles , thread , delegate BeginInvoke.
You should use some kind of synchronization object, for example ManualResetEvent, so the main thread will not execute when calling Application.Exit(). Or you can use some event to find out when the operation will end, and then call Application.Exit()(or call it inside ArchiveFiles), but I think it will be worse.
source
share