0

I am writing an application that does a blocking operation on the main thread using dispatch_sync_f when toggled (input from keyboard). I have a while loop inside the function that was passed to dispatch_sync_f that performs some routines. To ensure window events are processed while in this loop, I wrote the following and pass it along.

event = [NSApp nextEventMatchingMask:NSAnyEventMask 
                                     untilDate:nil
                                     inMode:NSDefaultRunLoopMode 
                                     dequeue:YES];

[NSApp sendEvent:event]

However, when I try to go fullscreen (green button) it is stuck until this blocking function is untoggled. I thought I was passing along all events any keyboard/mouse input to the window is processed. But going fullscreen may not have been an event in this case. Is there a way to detect fullscreen event and pass it to the window while the main thread is blocked?

jaykumarark
  • 2,359
  • 6
  • 35
  • 53
  • 1
    What if going full-screen is implemented by queuing tasks to the main dispatch queue, which you are occupying with your long-running task? It is not sufficient to process events. You need to free up the main queue. Why are you doing a blocking operation on the main queue? What kind of operation is it? – Ken Thomases Aug 19 '16 at 02:09
  • Please show the code including `dispatch_sync_f()`. – Amin Negm-Awad Aug 19 '16 at 06:45

0 Answers0