Questions tagged [dispatch-async]

437 questions
1
vote
1 answer

Mysterious EXC_BAD_ACCESS on dispatch_async *serial queue*

I have a location-based app that gets location every 1 second, and saves a batch of the locations at a time to the CoreData DB so as not to make the locations array too large. However, for some reason it crashes with EXC_BAD_ACCESS even though I use…
Uzumaki Naruto
  • 547
  • 5
  • 18
1
vote
0 answers

Swift GDC background process freezes app

I've written the function that launches Tor process. It's a process that won't stop until SIGTERM is sent to it, so, to avoid app freezing, I run this process in a background queue (Tor needs to be launched when the application is started and…
pomo_mondreganto
  • 2,028
  • 2
  • 28
  • 56
1
vote
0 answers

how to dispatch async block after X seconds from non-ui thread to the ui? using swift

From a non-view controller class I want to pop up to the ui a custom like- toast message. I want it to appear for 2 seconds. I know I need to use dispatch_async twice. One for unhiding the message Second for hiding the message after 2 seconds. This…
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
1
vote
1 answer

UIStoryboard instantiateViewControllerWithIdentifier: Can we call this in background thread?

I'm trying to call instantiateViewControllerWithIdentifier of storyboard in background thread. But I'm presenting it on main thread. Is there good way to do so? Please give me your suggestions. My code is something like…
1
vote
0 answers

Setting priority of queue created using dispatch_queue_create

I am trying to create a concurrent/serial queue using the dispatch_queue_create and set it's priority to "HIGH" by setting a High priority queue as it's target queue. However, the result on console is unexpected. Why exactly is this happening?…
1
vote
0 answers

Who's preventing my dispatch queues from being released?

In an app I'm working on for a client I create several concurrent dispatch queues at startup and then add long-running tasks to them using dispatch_async. When the app gets ready to shut down, I set a global quit variable that causes the…
Duncan C
  • 128,072
  • 22
  • 173
  • 272
1
vote
1 answer

NSTimer does not invalidate

I have a problem invalidating my timer. @property (nonatomic, strong) NSTimer *timer; Inside my block on success, I am allocating and setting my timer on main thread: dispatch_async(dispatch_get_main_queue(), ^{ self.timer = [NSTimer…
Flipper
  • 1,107
  • 1
  • 11
  • 32
1
vote
2 answers

Using serial dispatch queue for calling a method which accepts completion block as a parameter

I have a method : -(void) dataForRequest:(NSMutableURLRequest*)url withCallback:(void (^)(NSData* data))callbackBlock` which gets data from the URL in the background, and then calls the callbackBlock with the received data. I'm calling this on a…
1
vote
1 answer

NSMangedObjectContext performBlock in background issue

I read this article to save objects in Core Data database in background. In the end of the article they have this code to save data in background: [temporaryContext performBlock:^{ // do something that takes some time asynchronously using the…
Paul T.
  • 4,938
  • 7
  • 45
  • 93
1
vote
2 answers

iOS - When To Call UI Changing Functions In The Main Thread

Every time I make an API call to my server to get data, I already know that I have to use the following block to execute UI changing commands because my API call executes in the background thread: dispatch_async(dispatch_get_main_queue(), ^{ …
Rafi
  • 1,902
  • 3
  • 24
  • 46
1
vote
1 answer

core data insert big data in background

I want my application to load all server information to Core Data entity in background. I have created new entity called 'Event' then created 5 attributes in it. Also, I created NSManagedObject subclass for my entity: import Foundation import…
mkz
  • 2,302
  • 2
  • 30
  • 43
1
vote
1 answer

Lame Encoding iOS in queue

I'm trying to convert a WAV file into MP3 file using LAME. I am using this code. I want to do this in background (or in a queue). As input file is large, it can take the full control to it till finishing. Can anybody help me to do so? int read,…
Duni Chand
  • 13
  • 2
1
vote
1 answer

Swift update UILabel with dispatch_async not working

Why doesn't this work? dispatch_async(dispatch_get_main_queue(), { self.timeStringLabel.text = "\(self.timeStringSelected)" println(self.timeStringLabel.text) }) I'm trying to update a label in Swift but the UI for the label never changes.…
josealvarado111
  • 565
  • 1
  • 9
  • 24
1
vote
2 answers

Canceling previous call of dispatch_async

I'm implementing a tracking mechanism of window A following the position of window B. Window B sending events of its position and window B reacts to those events by calling to setWindowProperties: void setWindowProperties(bool topMost, bool visible,…
Sanich
  • 1,739
  • 6
  • 25
  • 43
1
vote
1 answer

ios cancel dispatch_async task

I have a background task that upload images and videos to the server. The user can cancel this operation in the middle. I was wondering if there is an easy way to notify the tasks to stop instead of having a boolean that needs to be checked in…
Boaz
  • 4,864
  • 12
  • 50
  • 90