kuba_z2
kuba_z2
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
Hello, is there any way to check if ISymbol was autogenerated by c# compiler? In this case checking for specialname attribute should be ok. I want to filter out autogenerated symbols such as methods generated from autoproperties or enums' value__ field.
20 replies
CC#
Created by kuba_z2 on 1/16/2023 in #help
✅ ClientWebSocket concurrency question
Hello. Can ReceiveAsync and CloseAsync methods be used concurrently? And also the same for SendAsync and CloseAsync (this one sounds a bit funny but it's serious). The documentation doesn't say anything about concurrency for CloseAsync.
2 replies
CC#
Created by kuba_z2 on 11/14/2022 in #help
❔ ❔ ❔ SemaphoreSlim that can be entered without waiting
Hello, I am trying to find way to easily control how much threads can enter semaphore. I need something like SemaphoreSlim but that supports entering without waiting or Releasing with minus values. For example:
await semaphoreSlim.WaitAsync();
try
{
if (something)
semaphoreSlim.Release(10); // allows 10 more threads to enter
else
semaphoreSlim.Release(-10); // limits 10 threads from entering
}
finally
{
semaphoreSlim.Release();
}
await semaphoreSlim.WaitAsync();
try
{
if (something)
semaphoreSlim.Release(10); // allows 10 more threads to enter
else
semaphoreSlim.Release(-10); // limits 10 threads from entering
}
finally
{
semaphoreSlim.Release();
}
I there any built in object to do it? I really don't want to implement such thing myself.
5 replies
CC#
Created by kuba_z2 on 8/17/2022 in #help
Process.EnableRaisingEvents does not work on Windows
I have an app that have 20 workers that are other processes. On production, on ubuntu, when I close the main process with ^C, the workers die as they should, but on Windows, when I kill the process, the workers still exist and use 100% of my i9-12900k (lol), it's because the workers have endless loops and throw exceptions in them when there is no main process. When I close app console window, the main process and workers are not closed and when I kill the main process, I have 100% of cpu usage. Did I miss something? I use this method to create a worker:
private Process CreateProcess()
{
var process = new Process()
{
StartInfo = new("ScriptingService", _arguments),
EnableRaisingEvents = true,
};
process.Start();
return process;
}
private Process CreateProcess()
{
var process = new Process()
{
StartInfo = new("ScriptingService", _arguments),
EnableRaisingEvents = true,
};
process.Start();
return process;
}
5 replies