FusedQyou
✅ How do I gracefully asynchronously exit a console application?
I am working on a console application that runs an asynchronous method until the console application exits. I want to gracefully exit this method and handle remaining work before fully closing.
The code currently looks like this (only relevant code shared)
Program.cs
: https://gdl.space/acabuvokev.cs
BotApplication.cs
: https://gdl.space/tumeduveko.cs
Expected: The console logs Stopped application.
.
Actual: The last message was Starting bot.
.
Is this possible at all? I want to add additional logic below before the console is exited, but I can't figure out the correct way of doing this.55 replies
My socket won't send data to 600 endpoints
My application sends a packet to 600 servers in order to gather data about active players and such.
My old code would use a parallel loop and this worked fine but was incredibly slow.
After removing it my code is much faster, but only 58 out of the 600 servers now return data.
Is there some limitation on how much data a socket can handle at once?
This is the method used. The endPoints array would contain 600 endPoints.
I verified the method only parsed about 58 servers by checking how many of the pending builders actually ende dup getting parsed.
At the bottom you see a loop that checks for pending builders that did not get parsed and this shows the timed out servers.
https://gdl.space/irafuvuvam.cs
44 replies
❔ Best way to set up a websocket and API to access the data?
I'm working on a website that gathers data through a websocket on the backend, using raw UDP packets. The protocol indicates that I can request data, and then immediately receive that data in batches until a special code is retreived to indicate the end of the collection. I want to display this data on the frontend by calling an API to fetch it.
The big challenge here is how I set up the backend to properly contain the data. I was thinking of having a background task occasionally fetch the data in an interval, and then have it store the data in a database. The API then always has this data available, or it will wait a bit whilst the newer batch is fetched.
Would this be viable, or is there a better way to fetch the data and making sure the API always retrieves the data for the frontend? How can I properly create a background task that is invoked every 5 minutes so that I can fetch the data?
33 replies
❔ Check if Type is static
This question is probably vague as shit, but I always do this check to ensure a type is static:
So, this works because static classes are declared abstract and sealed at the IL level.
My question is if this is actually valid and won't fail, ever. C# doesn't exactly have a
isStatic
field or something.5 replies
✅ This EntityFramework query can not be translated for SQLite
The issue lies within
Intersect
. The point of the query is to fetch the current user, and to populate LikedByUsers
with matched users. An user is matched when he appears in LikedByUsers
and LikedUsers
. How can I make this work for SQLite?
Error: "Translating this query requires the SQL APPLY operation, which is not supported on SQLite."
36 replies
❔ Unable to get automapper's projectTo() to work properly.
I need to use ProjectTo() to properly cast a query into a DTO, but in this case my user can only contains pictures which have
Deleted = false
. The code below works, but all photo's are returned, including deleted ones. The commented Include()
works fine, but I need the mapping to happen on query level, and not after, because of the creation of a paginatedList. If I map later, the PaginatedList misses crucial information, and I do not want to change its behaviour.
How can I replicate Include
to work with projectTo? As said above, the current version is allowed, but deleted photo's are returned too.28 replies