Re: Asynchronous call of Selector - is this code OK?
Re: Asynchronous call of Selector - is this code OK?
- Subject: Re: Asynchronous call of Selector - is this code OK?
- From: Manfred Lippert <email@hidden>
- Date: Fri, 01 Feb 2002 22:38:58 +0100
>
I think it will work fine
Great. I also was quite sure about that, but I wanted to get 100% sure. I
got two comments from others who also say that it will cause no problems.
Thank you all!
>
but please don't do it.
I have my reasons for doing that:
NSDocument:revertDocumentToSaved brings up a sheet ("Really want this?") and
then calls NSDocument:readFromFile _while_ this sheet is open. I have a
special case where I have to run some code _after_ the sheet is gone, but it
seems there is no method called after the sheet. I couldn't find any other
way than looking from time to time if my window has a sheet attached
anymore, and I have done this with the "delayed" function like in my sample
code where the "Condition" is "no sheet attached".
It works fine here, but I wanted to get sure that no bad things (stack
overflow) happen if the user went away leaving the sheet open for a very
long time ...
But it is quite clear now that it will not make any problems.
>
The problem is that it is massively inefficient, and is based on
>
polling.
No, it is based on (repeating) Timers. And the "afterDelay" value is greater
in my real program as I postet on the little example code in my previous
mail. I only look a few times per second if the sheet is gone. I don't think
this will waste too much CPU time ...
And normally the user kicks away the sheet immediately.
I also could have solved the problem with repeating NSTimers, but I think
internally it would end up the same.
Regards,
Mani