Pascal
✅ async/await and parallelism
So there is a chance for a race condition here. While the other command invokes
_message.Any
(which may enumerate the _messages
, in your case it seems like it does), PopMessage
will try to mutate _message
. It is important to remember that C# is not single threaded, async continuation may happen on a different thread (default thread pool, unless configured otherwise). Also note that waited = _messages.Any(_ => _ is Type31Message86 or Type30Message86);
may iterate over multiple items before the condition is satisfied. The quickest solution is to use a concurrent data structure provided in the language.79 replies
❔ Docker: Dotnet restore just loading
I don't think
/
is normal here, your project is definitely not in the root folder of the container. Your project files are instead copied to /src
, so it does not make sense to tell dotnet restore
to restore a project at /BackendForFrontend.csproj
when it is not there.35 replies
For-Loop doesnt work.
the issue with your code is that
threadCounter
, is sometimes unassigned. So the compiler does not know what to do when the value is unassigned and yet you are trying to access a value from it. you can fix this by assigning a default value to threadCounter
. Something like int threadCounter = 0
or whatever your default value is.72 replies
❔ Determine what variable is being referenced
You would have to use
Unsafe.AreSame<int>(ref someRef, ref someVar)
(https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.unsafe.aresame?view=net-7.0#system-runtime-compilerservices-unsafe-aresame-1(-0@-0@)) to compare the references in this case. You don't want to use ReferenceEquals(someRef, someVar)
due to boxing for value types.15 replies
❔ What is the appropriate way to confirm User ID for API
in your controller endpoint you have access to the
User
object. Which you can use to pass down the logged in user id User.FindFirstValue(ClaimTypes.NameIdentifier)
. If your service should only be used in an http scope, then you may go with one of the suggestions above.25 replies
✅ Containers orchestration
There are lots of content and topics to cover with container orchestration, since your aim is to learn you may want to consider the Kubernetes approach (it is the industry standard for container orchestration). On windows you can enable kubernetes using Docker Desktop and on linux you can install Minikube. Then again you will have to read through kubernetes docs, Getting Started. When you feel comfortable defining and deploying kubernetes resources, then you may want to take it a step further and try setting up a cluster.
7 replies