Skip to content

Commit

Permalink
do timer creation on a bg thread
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanArbuckle committed Mar 8, 2021
1 parent 3c5a643 commit d289ac4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/CRCarplayWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,17 @@ - (void)sceneMonitor:(id)arg1 sceneWasDestroyed:(id)arg2
- (void)startInactivityTimer
{
LOG_LIFECYCLE_EVENT;
[self killInactivityTimerIfNeeded];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self killInactivityTimerIfNeeded];

// Only start the timer if auto-hide is enabled
if ([[CRPreferences sharedInstance] autohideDock])
{
_inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(handleInactivity) userInfo:nil repeats:NO];
[_inactivityTimer retain];
}
// Only start the timer if auto-hide is enabled
if ([[CRPreferences sharedInstance] autohideDock])
{
_inactivityTimer = [NSTimer timerWithTimeInterval:2 target:self selector:@selector(handleInactivity) userInfo:nil repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:_inactivityTimer forMode:NSRunLoopCommonModes];
[_inactivityTimer retain];
}
});
}

- (void)killInactivityTimerIfNeeded
Expand Down

0 comments on commit d289ac4

Please sign in to comment.