Process exits without reading anything from chat. #4
Answered
by
Bukk94
XcomReborn
asked this question in
Q&A
-
I am trying to connect to a chat room and simply read the messages using the example code.
However this just exits immediately, am I doing something wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
Bukk94
Jun 6, 2024
Replies: 1 comment
-
Your example seems correct @XcomReborn. The reason why it exits immediately is that listening is non-blocking. You need to run this code as background task and keep your console up and running, or add some blocking calls to avoid application exit. Try adding infinite loop after while(true)
{
await Task.Delay(500);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
XcomReborn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your example seems correct @XcomReborn. The reason why it exits immediately is that listening is non-blocking. You need to run this code as background task and keep your console up and running, or add some blocking calls to avoid application exit.
Try adding infinite loop after
await client.ConnectAsync()
line. Something like: