kuba_z2
kuba_z2
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
yeah, I was thinking about it, thanks
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
thanks @AntonC, now only handling value__ for enums is left
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
nice
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
it seems to work for autoproperties
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
please, can someone help?
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
by the compiler
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
to the symbols
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
it's not being added
20 replies
CC#
Created by kuba_z2 on 3/10/2023 in #help
❔ Checking if ISymbol was autogenerated
no, it is false even though a method is generated from autoproperty and also for value__ field for enums
20 replies
CC#
Created by kuba_z2 on 1/16/2023 in #help
✅ ClientWebSocket concurrency question
I have found the explanation in source code
/// Thread-safety:
/// - It's acceptable to call ReceiveAsync and SendAsync in parallel. One of each may run concurrently.
/// - It's acceptable to have a pending ReceiveAsync while CloseOutputAsync or CloseAsync is called.
/// - Attempting to invoke any other operations in parallel may corrupt the instance. Attempting to invoke
/// a send operation while another is in progress or a receive operation while another is in progress will
/// result in an exception.
/// Thread-safety:
/// - It's acceptable to call ReceiveAsync and SendAsync in parallel. One of each may run concurrently.
/// - It's acceptable to have a pending ReceiveAsync while CloseOutputAsync or CloseAsync is called.
/// - Attempting to invoke any other operations in parallel may corrupt the instance. Attempting to invoke
/// a send operation while another is in progress or a receive operation while another is in progress will
/// result in an exception.
~ https://source.dot.net/#System.Net.WebSockets/System/Net/WebSockets/ManagedWebSocket.cs,8eecb48ae7d8e666
2 replies
CC#
Created by kuba_z2 on 11/14/2022 in #help
❔ ❔ ❔ SemaphoreSlim that can be entered without waiting
Ok, I had to write it myself:
internal class AdjustableSemaphoreSlim
{
private readonly object _lock = new();
private readonly LinkedList<TaskCompletionSource> _sources = new();
private int _count;

public AdjustableSemaphoreSlim(int initialCount)
{
_count = initialCount;
}

public void Release()
{
lock (_lock)
{
_count++;
if (_sources.Count != 0)
{
_sources.First!.Value.SetResult();
_sources.RemoveFirst();
}
}
}

public void Release(int count)
{
lock (_lock)
{
_count += count;
for (int i = Math.Min(_sources.Count, count); i > 0; i--)
{
_sources.First!.Value.SetResult();
_sources.RemoveFirst();
}
}
}

public void Enter(int count)
{
lock (_lock)
_count -= count;
}

public Task WaitAsync()
{
lock (_lock)
{
if (--_count >= 0)
return Task.CompletedTask;
else
{
TaskCompletionSource source = new();
_sources.AddLast(source);
return source.Task;
}
}
}
}
internal class AdjustableSemaphoreSlim
{
private readonly object _lock = new();
private readonly LinkedList<TaskCompletionSource> _sources = new();
private int _count;

public AdjustableSemaphoreSlim(int initialCount)
{
_count = initialCount;
}

public void Release()
{
lock (_lock)
{
_count++;
if (_sources.Count != 0)
{
_sources.First!.Value.SetResult();
_sources.RemoveFirst();
}
}
}

public void Release(int count)
{
lock (_lock)
{
_count += count;
for (int i = Math.Min(_sources.Count, count); i > 0; i--)
{
_sources.First!.Value.SetResult();
_sources.RemoveFirst();
}
}
}

public void Enter(int count)
{
lock (_lock)
_count -= count;
}

public Task WaitAsync()
{
lock (_lock)
{
if (--_count >= 0)
return Task.CompletedTask;
else
{
TaskCompletionSource source = new();
_sources.AddLast(source);
return source.Task;
}
}
}
}
5 replies
CC#
Created by kuba_z2 on 8/17/2022 in #help
Process.EnableRaisingEvents does not work on Windows
oh, so I misunderstood it (actually found a response on StackOverflow that told EnableRaisingEvents makes process die after main process is closed some time ago). Is there any easy way to make child processes die after main process is closed?
5 replies