FROM : j o a r
DATE : Mon Apr 11 20:59:10 2005
I wouldn't use a thread for this purpose alone - it doesn't smell right.
I would assume that you perform the open+download+close operation in
one event loop? that is probably why the window doesn't behave like
you would expect. Try to just launch your download operation on a
timer. Something like this:
- (void) myConnectionCallback:(id) sender
{
[self doTheStuffToOpenTheWindow];
[self performSelector: @selector(runDownloadOperation)
withObject: nil afterDelay: 0.0];
}
- (void) runDownloadOperation
{
// do whatever you do when you download
[myWindow close];
}
And, if the download operation is a long one (long == more than 1 - 2
second), you should probably place it on a thread, in which case this
trick with the timer won't be necessary at all. Having the download
operation on a thread seems like a much better design than the other
way around. Try to keep all UI operations on the main thread, and all
other lengthy operations on secondary threads.
j o a r
On 11 apr 2005, at 20.31, Ken Tozier wrote:
> Thanks Lorenzo. Threading did the trick!
>
> I'm a little confused as to why threading is necessary though. Is
> it always required to open nib files other than the main nib inside
> their own thread? If not, why was it necessary for this instance.
> I'm not doing anything fancy inside my code, just opening a window
> with [NSWindowController initWithWindowNibName:@"nibName" owner:
> self];
>
> Do you know if there is any documentation that spells out these
> types of hidden gotchas?
>
DATE : Mon Apr 11 20:59:10 2005
I wouldn't use a thread for this purpose alone - it doesn't smell right.
I would assume that you perform the open+download+close operation in
one event loop? that is probably why the window doesn't behave like
you would expect. Try to just launch your download operation on a
timer. Something like this:
- (void) myConnectionCallback:(id) sender
{
[self doTheStuffToOpenTheWindow];
[self performSelector: @selector(runDownloadOperation)
withObject: nil afterDelay: 0.0];
}
- (void) runDownloadOperation
{
// do whatever you do when you download
[myWindow close];
}
And, if the download operation is a long one (long == more than 1 - 2
second), you should probably place it on a thread, in which case this
trick with the timer won't be necessary at all. Having the download
operation on a thread seems like a much better design than the other
way around. Try to keep all UI operations on the main thread, and all
other lengthy operations on secondary threads.
j o a r
On 11 apr 2005, at 20.31, Ken Tozier wrote:
> Thanks Lorenzo. Threading did the trick!
>
> I'm a little confused as to why threading is necessary though. Is
> it always required to open nib files other than the main nib inside
> their own thread? If not, why was it necessary for this instance.
> I'm not doing anything fancy inside my code, just opening a window
> with [NSWindowController initWithWindowNibName:@"nibName" owner:
> self];
>
> Do you know if there is any documentation that spells out these
> types of hidden gotchas?
>
| Related mails | Author | Date |
|---|---|---|
| Ken Tozier | Apr 11, 17:54 | |
| Lorenzo | Apr 11, 19:03 | |
| Ken Tozier | Apr 11, 20:31 | |
| j o a r | Apr 11, 20:59 | |
| Ken Tozier | Apr 11, 21:59 | |
| Ken Tozier | Apr 12, 03:51 | |
| Charilaos Skiadas | Apr 12, 04:13 | |
| Ken Tozier | Apr 12, 06:32 | |
| Charilaos Skiadas | Apr 12, 07:06 | |
| Ken Tozier | Apr 12, 07:35 | |
| Hamish Allan | Apr 12, 13:52 |






Cocoa mail archive

