Questions tagged [dispatch-async]
437 questions
4
votes
0 answers
ALAssetLibrary performBlockAndWait (GUI hang issues)
I am writing an image uploader which indexes the camera roll on certain events, creates jobs, and then writes those jobs into CoreData. Another thread reads from CoreData to upload the images.
I keep getting UI freezes. Event though the GUI is…

VaporwareWolf
- 10,143
- 10
- 54
- 80
4
votes
2 answers
Does dispatch_async block to serial queue keeps order?
When I submit two blocks into a serial queue by dispatch_async, does it assure the second one runs after the first one:
dispatch_async(serial_queue, b1);
dispatch_async(serial_queue, b2);
can we assure b1 runs before b2?
Below is full source code…

AnkyHe
- 76
- 1
- 6
3
votes
2 answers
DispatchQueue.main.asyncAfter not delaying
My DispatchQueue.main.asyncAfter execution block does not wait to execute.
I wrote a MacOS single view app. (xCode 12.0.1 (12A7300)). It has a for-loop that calls a function that downloads content from my server. I want to throttle the requests. I…

sebrenner
- 73
- 1
- 6
3
votes
3 answers
UILabel text is not updated even in MainThread
UILabel.text is not updated inside the main thread. labelOne is updated but labelTwo which is to show translated word is not updated. When I print translatedWord it prints right string to console but UILabel is not updated.
datatask =…

Selçuk Yıldız
- 539
- 1
- 5
- 14
3
votes
1 answer
Android: Dispatch queue
I am building an app that will make a web request whenever you scan a qr code. If you have internet available, making that request is easy. If we don't have internet, I want to put it onto a queue and make those requests whenever I have internet on…

Arham Akbar
- 41
- 1
- 4
3
votes
3 answers
Nested async calls in Swift
I'm kind of new to programming in general, so I have this maybe simple question. Actually, writing helps me to identify the problem faster.
Anyway, I have an app with multiple asynchronous calls, they are nested like…

Max Kraev
- 740
- 12
- 31
3
votes
1 answer
Forcing all UIKit stuff to be done in the main thread
I am doing a complex application that has to do stuff on a lot of threads and frequently update the interface.
So I have to add a lot of
dispatch_async(dispatch_get_main_queue(), ^{
});
in the middle of the code to dispatch UI updates to the…

Duck
- 34,902
- 47
- 248
- 470
3
votes
1 answer
React + Redux - dispatching an action in dumb component?
I started learning Redux and the whole idea looks neat, but after rebuilding my React app from "normal" to "redux-way" this problem came up.
I have a list of if items that I build based on JSON from async call. Then every item on that list sends an…

Wordpressor
- 7,173
- 23
- 69
- 108
3
votes
1 answer
Why does it take such a long time for UI to be updated from background thread?
I understand that all UI updates must be done from Main thread.
But purely for the sake of deeper understanding how GCD and dispatch main work:
I have a button that runs a network call and in its completionHandler I eventually…

mfaani
- 33,269
- 19
- 164
- 293
3
votes
4 answers
Swift 3 : URL Image makes UITableView scroll slow issue
I have an extension to print image URL on UIImageView. But I think the problem is my tableView is so slow because of this extension. I think I need to open thread for it. How can I create a thread in this extension or do you know another solution to…

jorjj
- 1,479
- 4
- 20
- 36
3
votes
2 answers
Swift 3: capture strong self in @escaping closure without asynchronous work
There is a protocol with the following declaration:
typealias SuggestionSourceCallback = ([Suggestion]) -> ()
protocol SuggestionSource {
func suggest(_ query: SuggestionQuery, callback: @escaping SuggestionSourceCallback)
}
Two classes…

Yevhen Dubinin
- 4,657
- 3
- 34
- 57
3
votes
4 answers
Syntax to wrap a completion handler in dispatch async
I have a completion handler that I need to assign to a property, but I want it to execute asynchronously.
If I didn't have that requirement, I would write:
request.completionBlock = completionBlock
But since I have this requirement, I have to…

KPM
- 10,558
- 3
- 45
- 66
3
votes
2 answers
Get a thread by name/label in Objective-C
I would like to know if there is a way in Objective-C to get a thread by its name or label?
dispatch_queue_t newQueue = dispatch_queue_create(@"NameOfTheQueue", NULL);
This creates the queue. So, in another module, is there a way to get that…

Jeff
- 39
- 2
3
votes
2 answers
dispatch_async vs dispatch_sync in fetch data. Swift
After reading so many posts about parallel and concurrent, I still confuse what is the proper way to fetch data. For example, in my project, I have a button for user to fetch data. My code is something like below.
var array = [Int]()
func…

Pak Ho Cheung
- 1,382
- 6
- 22
- 52
3
votes
2 answers
"This application is modifying the autolayout engine" error (Swift iOS)
I am stuck figuring out how to fix an "This application is modifying the autolayout engine from a background thread" error. Any help is greatly appreciated.
I tried the approach outlined from this similar question to use…

Ben
- 3,346
- 6
- 32
- 51