Replies: 2 comments
-
Hi @ykarpeev yes, this can absolutely happen if you use async events. There isn't a good way as far as I know to ensure in-order async processing. It's really up to the CLR to schedule the work at that point. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you. I'll set it to false by default on my end. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am trying to figure out if I am doing something wrong, or if when UseAsyncDataReceivedEvents is enabled which it is by default - data comes in out of order.
I've created a test case here:
This is the kind of output I see:
`Received: -------- 0
Received: -------- 19
Received: -------- 25
Received: -------- 30
Received: -------- 17
-------- 18
Received: -------- 28
-------- 29
Received: -------- 43
Received: -------- 50
-------- 51
Received: -------- 44
-------- 45
-------- 46
-------- 47
-------- 48
Received: -------- 49
Received: -------- 31
-------- 32
Received: -------- 67
-------- 68
Received: -------- 52
Received: -------- 61
-------- 62
-------- 63
-------- 64
-------- 65
-------- 66
Received: -------- 60
Received: -------- 33
Received: -------- 75
-------- 76
-------- 77
Received: -------- 69
Received: -------- 70
-------- 71
-------- 72
-------- 73
-------- 74
Received: -------- 78
Received: -------- 86
-------- 87
-------- 88
Received: -------- 79
-------- 80
-------- 81
-------- 82
-------- 83
-------- 84
Received: -------- 85
Received: -------- 90
-------- 91
-------- 92
-------- 93
Received: -------- 95
-------- 96
-------- 97
-------- 98
-------- 99
Received: -------- 94
Received: -------- 34
Received: -------- 35
-------- 36
-------- 37
Received: -------- 89
Received: -------- 53
-------- 54
-------- 55
-------- 56
-------- 57
-------- 58
-------- 59
Received: -------- 27
Received: -------- 26
Received: -------- 38
-------- 39
-------- 40
Received: -------- 22
Received: -------- 23
Received: -------- 24
Received: -------- 42
Received: -------- 20
Received: -------- 21
Received: -------- 10
-------- 11
-------- 12
-------- 13
-------- 14
-------- 15
-------- 16
Received: -------- 1
-------- 2
-------- 3
-------- 4
-------- 5
-------- 6
-------- 7
-------- 8
-------- 9
Received: -------- 41`
UseAsyncDataReceivedEvents set to false will make it work as expected.
My initial guess is that the issue could be in this code and that Task.Run() doesn't run in order.
Am I missing something? Handling datareceived incorrectly? Should this be await Task.Run(action, token) instead? Anyone seeing the same?
Beta Was this translation helpful? Give feedback.
All reactions