I have a background thread that does a ton of work - loading the application. The main thread shows the progress on the UIProgressView.
A background thread is created using performSelectorInBackground (although I disagree with this method if a different approach makes this easier)
[self performSelectorInBackground:@selector(loadAppInBackground) withObject:self];
In several cases, an error caused the background thread to fail (various errors during application development), which leads to a stop of the progress bar, but the user does not receive a clear indication that something is wrong.
I would like to discover this situation and fail more gracefully than just hang it until the user abandons the wait.
Since the duration of the download process can vary greatly, just timing is not an ideal option.
What is the best way for a foreground thread to detect that a background thread has failed? Since the foreground thread is busy working with the user interface, will a second background thread be required to monitor the first? It seems ugly.
Is there any mechanism for connecting threads to a thread that can be used to ping the background process? Better yet, a low-level system mechanism for checking the status of other threads?
The debugger knows about all the threads that work ... and seems to know their status. I am wondering if there is access to my application to do the same.
source share