I never reach the return, and i dont know why?
I have this Task: (Picture 1), which also calls two other Tasks (Picture 2 and Picture 3).
However i never reach the return of the first Task, and i dont understand why? The Program breaks out of the while(true) loop in Picture 3, and then the original Task (Picture 1) is not continuing.
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1125416483930001458/Discovery1.png)
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1125416484332638369/Discovery2.png)
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1125416484726919268/Discovery3.png)
12 Replies
first of all await waits for the task to finish
so that timeout isnt acting as a timeout
because u await that
ReceiveDiscoveryResponseAsync()
finishes and only some time afterwards close the socket
u basically have something like
preferably use a cancellation token
and pass it around
and dont have SendMessageBlaBla call RecieveBlaBla
also please use $codeblocks to provide code, screenshots are annoying
when reading that code i had no idea _chatrooms was being mutated
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/Okay thanks for the responses. I will further think about it and try your solutions
That helped a lot.
I changed
await chatroomList = await discovery.StartDiscoveryAsync();
into
chatroomList = await discovery.StartDiscoveryAsync();
That did the trick.
Thank you really much.but the first isnt valid syntax
where was that anyway
oh its when i call the task on my application.
But when i think about it, the delay really doesnt do anything. Need to think about it for a sec.
yes thats what im saying
you probably want something like this:
I will take a good look at this in the evening. Looks really good on the first look