Questions tagged [.net]

.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

Filter by
Sorted by
Tagged with
2 votes
3 answers
2k views

ObservableQueue

I'm looking for feedback on this. ...
-2 votes
0 answers
12 views

How to optimize the Asp.net Core WebAPI code? [closed]

I am building a .Net Core 6.0 application that uses HttpClient I have a custom Httpclient as mentioned below ...
10 votes
2 answers
2k views

List the movies I haven't seen

I am new to programming and have been taking the time to learn C# by reading, doing some classes online for Unity, and using Youtube. I think you learn more from doing your own projects so I decided ...
1 vote
1 answer
96 views

Asynchronous tasks to subscribe to orders and fills

Pretty straightforward question. The methods SubscribeToOrdersAsync and SubscribeToFillsAsync are pretty similar due to ...
0 votes
0 answers
47 views

BaseController with Generic Entity and Model

I created a controller with generic TEntity and TModel so that i will not have to repeat common actions like save/delete for each entity. I just want to ask if this is a good or a bad practice? ...
0 votes
1 answer
65 views

ASP.NET Core simple DB cleaner background service

In an application there is a table for one-time-passwords (OTP) which will be sent to users via SMS. These OTPs are needed for a maximum of two hours in order to detect abusing behaviours. A simple DB ...
3 votes
1 answer
596 views

Run control tasks asynchronously using TPL

One of my classes regularly triggers one of two asynchronous operations: a "turn on" and a "turn off" that each take about a second. I'm using this method below to make sure that they don't run ...
5 votes
1 answer
805 views

C# Async FileInfo Extensions (Copy, Move, Delete)

Here is my effort to implement extensions for FileInfo object: ...
0 votes
0 answers
50 views

Redis Output Cache Store refactoring

This code incorporates the new .NET 7 Output Caching. I would like to get some refactoring tips on the RedisOutputCacheStore class. How to use ...
1 vote
1 answer
111 views

File Abstraction Library

This library is a layer of abstraction over file operations in C#. It aims to provide easy file IO syntax, and implicit error handling behaviors, to ensure robustness in scenarios including, but not ...
3 votes
1 answer
782 views

Barnes-Hut implementation of the N-Body problem translated from F# to C#

I am after a peer review of a C# implementation of the Barnes-Hut algorithm which I have translated from F#. The F# version is the base for comparison, therefore the C# version is suppose to reflect ...
0 votes
0 answers
47 views

Filter duplicate events raised by FileSystemWatcher

As you know about FileSystemWatcher Events, which may fired twice or more according to OS handling, For example creating a .txt file may fires two events (1)For ...
2 votes
2 answers
101 views

C# Binary Search Tree implementation

I have implemented a Binary Search Tree and would really appreciate it if someone could take time to check it and give me feedback. I try to keep my code clear and simple. Is it readable? Is the API ...
2 votes
1 answer
103 views

ASP.NET Core background logger queue with dynamic workers

In a docker compose environment there are several apps that communicate with each other. One of these apps is a logger (a centralized logger). Every part of the system that needs to log something, ...
7 votes
1 answer
341 views

AutoResetEventAsync, am I missing something?

So I wrote an asynchronous version of AutoResetEvent: ...
0 votes
1 answer
73 views

Improving multiple FirstOrDefault statements on same collection

I'm having multiple FirstOrDefault() statements, in this case 2, on a collection. ...
6 votes
1 answer
8k views

Use and understanding of async/await in .NET 4.5 +

I am just about to embark upon a massive job of multi-threading a cost-engine. I could use TPL of which I am very familiar, but would like to leverage the async/<...
1 vote
1 answer
89 views

Serial port class wrapper for serial port object VB.NET

I've been reviewing some code recently, and I came across this wrapper object for the serial port class. I'm trying to understand the advantage of this seemingly redundant object: ...
0 votes
0 answers
67 views

ASP.NET Core 6 background DB logger

In an application, many actions need to be logged in the database. but this logging process should not slow down the request. So they should be done in an asynchronous queue or something. This is my ...
3 votes
1 answer
121 views

Console Slot Machine written in C#

This is my console simulation of the Slot Machine in C#. Please take a look at this code and point out possible ways of improvement. ...
1 vote
2 answers
123 views

Is this a good way to check for an anagram if sorting is not allowed?

So I decided to lookup some algorithms, and one of the ones I found was.. "Check if the string is an anagram" and without using Google for more than checking what an anagram is, I decided to ...
1 vote
1 answer
53 views

NTP client displaying reference, originate, receive and transmit timestamps periodically with graceful shutdown in C#

based on this stackoverflow topic: https://stackoverflow.com/a/12150289/15270760 I have decided to create a simple NTP client displaying difference between NTP server response and DateTime.Now called ...
0 votes
1 answer
75 views

Sorting Dictionary in a lexicographical order and applying MD5 encryption

I'm sorting a Dictionary in a lexicographical order and applying MD5 encryption. I would like to wrap the sorting somewhere inside the encryption method or so. Official Java example - here Docs <...
0 votes
0 answers
102 views

Subscription manager - use cases with same parameters

The idea behind the SubscriptionManager class was not just to keep the subscriptions and resubscribe on reconnect, but also to support multiple callbacks in case of ...
0 votes
0 answers
45 views

Hangfire context constructor injection

I tried following IHttpContextAccessor pattern but for Hangfire context. What I'm mostly interested in is CustomScope class with Resolve method. I'm using ActivatorUtilities there because otherwise I ...
2 votes
2 answers
96 views

Wielding .NET masterfully to encode non-alphanumeric characters into utf-8 hex representation

I have these two methods that work, but I also hate because they almost certainly can be improved. I'm hoping to gain some guidance from others who are more knowledgable of .NET's offering for ...
1 vote
1 answer
62 views

Initializing Class from constructor [closed]

...
1 vote
1 answer
2k views

Caching XmlSerializer in AppDomain

To work around the XmlSerializer memory leak thing I created this: ...
4 votes
1 answer
4k views

Recurring tasks in ASP.NET MVC

I have 2 alternatives for executing recurring tasks in ASP.NET MVC. We just need to add some code in Global.asax First alternative: ...
4 votes
1 answer
126 views

ForEachAsyncSemaphore asynchronously processing tasks but enable fast fail

I know this has been done many times before, but this is my existing code taken from a sample I found to async process a list of tasks. I've seen Task.Run in use before in many examples, but I'm ...
2 votes
1 answer
77 views

Managing websocket subscriptions

The following code is pulling data off an exchange. It keeps the subscriptions to the channels because when the websocket client reconnects, all subscriptions are gone and we basically need to ...
1 vote
0 answers
270 views

Implementation of Concurrent List in .NET

I would appreciate review of this implementation of the concurrent list that is, to my knowledge, currently missing in .NET Core. Requirements Thread safe Lock free Ordered Supports get and set by ...
1 vote
0 answers
115 views

Replacing multiple substrings in C#

There is a String.Replace method in C# and it is 1-1 mapping replacing operation, i.e. single Unicode character / string source replaced with another single Unicode ...
1 vote
0 answers
54 views

Specification pattern vs Always valid domain model [closed]

Let's say we have two aggregates: ...
1 vote
1 answer
393 views

General web socket client with auto reconnect capabilities

This is a web socket client wrapper with auto reconnect capabilities. First of all, I know I should avoid working with strings to reduce allocation, that's on test purpose. So, ignore the fact that it ...
0 votes
0 answers
39 views

Abstract instance creation for handler

My application uses several data sources. One is a web-service, the other uses a database context, and in some cases even files on servers have to be retrieved. I am trying to find a way to ...
0 votes
1 answer
84 views

Reading and modify big set of data

I have a method that iterate over my table question in database and then will split a column commentaires and finnally put ...
3 votes
1 answer
332 views

Convert a c# decimal to big-endian byte array

Following the avro schema documentation for decimals I've created a method to turn a decimal into a byte array. The goals are: Should be represented by a non-scaled integer Should be big-endian I've ...
1 vote
0 answers
58 views

F# thumbnail Scraper

Thumbnail Scraper I'm a C# programmer learning F#. For my first program I created a console youtube thumbnail scraper. It parses command line arguments with argu and then downloads the thumbnails, ...
3 votes
2 answers
441 views

Reading big csv file C#

I'm trying to read quite big file with around 28 million of rows in the following way: ...
2 votes
0 answers
81 views

Is this a valid implementation of Memento Pattern in C#?

I've been studying design patterns from GOF for a few weeks, especially in C#, and I'm struggling with Memento Pattern. I know there are a lot of C# implementations on the web, but I came up with my ...
2 votes
2 answers
203 views

Concise handling of async tasks with timeouts in c#

Often I have async functions that I want to be able to time out, this timeout is independent of the greater scope of the application. However the function should also take into consideration the ...
1 vote
3 answers
429 views

c# record parameter validation technique

This comes from an answer I provided to a question on stackoverflow here: https://stackoverflow.com/a/71482194/3258131 To make c# record parameter validation concise and maintain all the benefits of ...
1 vote
0 answers
98 views

Caching wrapper with multi-providers and factory to detect the responsible cache provider related to Type

What I'm trying to do abstract the caching actual cache provider (memory || distributed || ...). enable a caching diversity. each cached item type has different ...
1 vote
4 answers
113 views

Multiple if statements in a single method to enable/disable feature

I am sure this is not ideal code, basically I am checking a condition at a time and exiting if any of them are true. This will then disable refund functionality. ...
9 votes
2 answers
6k views

Using Roslyn to find interfaces within a solution

The intent of the below code is to find all interfaces within a solution whose fully-qualified names match the given predicate. It seems to work, but as I am new to Roslyn I'm guessing there are ...
-1 votes
1 answer
132 views

Whats the best way to refactor a POCO class

In work I was asked to fix a bug which involved me making changes in a class. To fix the bug I needed to add a collection of a class that looks like this. ...
3 votes
1 answer
642 views

In Memory Database in Unit tests, isolate the tests

I have stumbled across these unit tests in a code review that are using in memory db: ...
1 vote
1 answer
616 views

How to process multiple background concurrent Tasks in c#

I am trying to work out the best way to go about a task which relys on multiple long running tasks taking place. My use case is that I want to have multiple events running for set periods of time, ...
8 votes
1 answer
1k views

Card Shuffle without using any help C#

I'm new to C# but not 100% new to development. I wanted to try writing a Card Shuffle + Card Dealing algorithm using as least as possible inbuilt functions or any libraries and no internet use to ...

1
2 3 4 5
25