Hey Guys. I am having a problem with coroutines. I...
# announcements
d
Hey Guys. I am having a problem with coroutines. I have the next:
Copy code
GlobalScope.launch {
                CoroutineScope(a.context).launch {
                val b = c.await()
                store(b)
                println("Hello")
            }.join()
        }
where
a
is an object which contains a Coroutine context and
c
is a deferred value obtained from a calling a suspend function. It never prints
Hello
because there is a NullPointerException when tries to store
a
. Anyone knows why is it happening?? My target is to wait until the deferred value a is completed and then store it using the
store
function, which is not a suspend function.
l
Perhaps you're looking for
runBlocking
?
Or
async
await
?
d
I have tried with those solutions but it is not working for me and I don't undertand the problem
l
Why isn't it working?
d
It seems like it gets a null pointr exception when I use store a, but I don't know why
l
is this the only place you're using a?
d
sorry
there is a mistake in the code snippet
I have fixed it
g
What exactly you want to achieve with such code? Example looks incomplete (there is no a and c in your snippet), and overcomplicated
d
I think the problem is that
await
is throwing the npe and you're gonna need to find the code of that coroutine from the stacktrace.