https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

cak

12/13/2019, 11:43 AM
👋 all! I'm new to Kotlin and I am trying to use coroutines and Swing - the above code sort of works, but doesn't update the table ui until it has been pressed a few times - am I doing this right? https://github.com/TypeError/Bookmarks/blob/177801633a1e8f51ae8aad2c5e1bf034b83a9faa/src/BookmarkTab.kt#L158
d

diesieben07

12/13/2019, 11:46 AM
First thing I noticed is that you are accessing
repeatInTable
(which is a Swing component) from the IO thread. Swing is not threadsafe. Then, instead of launching another job using
launch
, you can just use
Copy code
withContext(Dispatchers.Swing) {
}
c

cak

12/13/2019, 12:48 PM
Thanks so much! I'll give those a try!
4 Views