The problem I'm having with the solutions you and Rolf propose is that one 
might end up with a couple of threads waiting to terminate. Imagin that 
switching to a tab in a tab controller  starts a thread that does some hefty 
work. Then user switches tabs and the thread is signaled to abort ASAP but the 
UI reacts instantly. A second later user switches again to the second tab. 
Another thread is started where the first one might not have reached the first 
point where it could exit (maybe it is still trying to reach a server over the 
net). Now there Are two threads. This can go on and on and while it is uncommon 
to cause problems I'm wondering if that is just as it is and I should not worry?

Grüße, René

Am 27.02.2012 um 14:52 schrieb Robert Jordan <[email protected]>:

> On 25.02.2012 21:50, René Ruppert wrote:
>> one thing I have been wondering about is, how quickly apps written in ObjC
>> can cancel threads.
>> 
>> Just one example: I have an app where I can check train schedules. I tell it
>> from where to where and it starts searching. Whenever I click some other
>> element in the tab bar, the search is interrupted immediately.
> 
> I fail to see a correlation between a responsive UI and
> the ability to kill threads really fast.
> 
>> Back in the good old days of .NET I was told: “Thread.Abort()” is evil!
>> Don’t use!”. So as a .NET developer I always have to abort in a clean way
>> but that makes apps less responsive. If you have to wait for the next web
>> call to return, for the next page to be rendered, etc it will be slow(er).
> 
> What prevents you from:
> 
> - reacting on user interaction (user clicks "Cancel")
> - updating the UI to reflect the cancel operation (remove
>  spinners, etc.)
> - setting a flag in a background thread
> - evaluating this flag from the background thread and leave it
>  gracefully some time later?
> 
>> If I check MSDN now, I see that Thread.Abort() will no longer abort finally
>> clauses. For me this means, Abort() no longer is that evil as it was because
>> you actually have a chance to clean up using a “finally” clause.
> 
> Abort is still cumbersome.
> 
> Robert
> 
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to