'WinUI3 What can cause a DispatcherQueue.TryEnqueue(action) return true, but not execute action?
My scenario is: a TCPClient receives Json objects and distributes them to different queues. Such a queue is handled in a Task like this (the dispatcher is necessary because Bind-Objects are getting changed):
public Task Run => Task.Run(async () =>
{
jsonResponse pk;
while ((pk = await q.WaitFor()) != null)
{
Debug.WriteLine(pk.debug_string());
if (!dispatcher.TryEnqueue(() => {
handlePacket(pk);
}))
{
int iDebug = 1;
};
}
});
handlePacket also outputs the packet content to Debug; the lines are labeled R (received from TCP), Nothing in the above code and H (inside the handlePacket). These lines
R{"prg":{"id":119,"title":"100ms time synchronous"}}
R{"prg":{"id":119,"done":1}}
R{"prg":{"id":125,"title":"1 s Raster"}}
{"prg":{"id":119,"title":"100ms time synchronous"}}
{"prg":{"id":119,"done":1}}
{"prg":{"id":125,"title":"1 s Raster"}}
H{"prg":{"id":119,"done":1}}
show that at least the first message is read from the queue but not handled; the first handled message is the second one (but it may also be the third or fourth)
I could not find any information about why this could happen.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|