• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: unresponsive button in panel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unresponsive button in panel


  • Subject: Re: unresponsive button in panel
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Sun, 20 Jul 2003 22:54:32 +0100

On Sunday, July 20, 2003, at 08:19 pm, M. Uli Kusterer wrote:

At 18:37 Uhr +0000 20.07.2003, Brad Peterson wrote:
My problem is that the cancel button is entirely unresponsive -- no matter how often I click it, as long as the app is in the middle of copying a set of files, I'm stuck waiting.

I suspect this has to do with the fact that I'm doing this all in the same thread, but I don't have a lot of choice there... I need everything to happen synchronously (that is, in a specific order with each piece waiting until the other is done) so that's intentional.

You have to give the OS an opportunity to process events. Several options come to mind:

1) Somehow call an NSApplication method that checks for new user events and processes them. I don't know whether there is such a method, though.
2) Do the copying in a separate thread (all of it). And check a global "cancel" variable at regular intervals, and if it is set, abort and kill the thread. Then, in your main thread, have the "Cancel" button set this variable to TRUE.

It's worth mentioning that if you're going to use method 2 with a global variable, then you need to declare the variable "volatile"; the only exception is if you're using something that's explicitly intended for thread-safety (for example an NSLock or a pthreads or Mach synchronisation object).

If you don't use the volatile keyword, your program may work, or it may not, depending on choices made by the optimiser, and minor changes to your program could change it from working to not working, and it will be difficult for you to debug.

Kind regards,

Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: unresponsive button in panel (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: Becomeing foreground process [was XRe: Problem receiving key events in CLI created window]
  • Next by Date: Re: Help: How do you start debugging this crashlog?
  • Previous by thread: Re: unresponsive button in panel
  • Next by thread: Compiler Craziness!
  • Index(es):
    • Date
    • Thread