Is it valid to have multiple signal handlers for same signal?

As said by others, only one signal handler can be set, which is the last one. You would then have to manage calling two functions yourself. The sigaction function can return the previously installed signal handler which you can call yourself. Something like this (untested code): /* other signal handlers */ static void (*lib1_sighandler)(int) = … Read more

What actually happens when using async/await inside a LINQ statement?

I recommend that you not think of this as “using async within LINQ”. Keep in mind what’s in-between the two: delegates. Several LINQ operators take delegates, and async can be used to create an asynchronous delegate. So, when you have an asynchronous method BazAsync that returns a Task: Task BazAsync(TBar bar); then this code results … Read more

How to mock IOptionsSnapshot instance for testing

You should be able to mock up the interface and create an instance of the options class for the test. As I am unaware of the nested classes for the options class I am making a broad assumption. Documentation: IOptionsSnapshot //Arrange //Instantiate options and nested classes //making assumptions here about nested types var options = … Read more

What is the preferred naming convention for Func method parameters?

There are precedents for using a noun in the Framework, e.g. Enumerable.Average<TSource>(this IEnumerable<TSource> source, Func<TSource, decimal?> selector) Enumerable.Count<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) Enumerable.GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) ConcurrentDictionary<TKey,TValue>.GetOrAdd(TKey key, Func<TKey, TValue> valueFactory); The noun is often an appropriate verb with an agentive suffix. In your example I would … Read more

Are there any benefits of reading each field async from a SqlDataReader?

After some peeking at reflector, the interesting methods here (GetFieldValueAsync<T>, IsDBNullAsync, and the internal method GetBytesAsync) only do “interesting” code for the CommandBehavior.SequentialAccess scenario. So: if you’re not using that: don’t bother – the row data is already buffered in memory, and Task<T> is pure overhead (although it will at least be an already-completed task … Read more

Set EventCallback outside of a Blazor component?

Turns out you can assign an event callback from C# code like this: this.ProgressManager.UpdateNotification = new EventCallback(this, (Action)Refresh); void Refresh() {} It also works with async methods, e.g.: this.ProgressManager.UpdateNotification = new EventCallback(this, (Func<ValueTask>)RefreshAsync); ValueTask RefreshAsync() {} UPDATE You can also use EventCallbackFactory to more conveniently create event callback objects, e.g.: new EventCallbackFactory().Create(this, Refresh)