.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.

learn more… | top users | synonyms

0
votes
1answer
60 views

Check before proceeding if the task in BackgroundWorker has completed

I have a Login Form (which has a label that will show status of background process, username and password text boxes, Login and Cancel buttons) along with that I have a background worker to do some ...
3
votes
1answer
59 views

Web API using Repository / UnitOfWork

I'm looking for feedback on a repository I set up based on a blog post I read here. I have just recently got more into .NET within the past year, so any feedback and/or best practices that can be ...
4
votes
1answer
54 views

Throttle actions by number per period

I want to throttle asynchronous actions at a specific maximum rate of n actions per t period, and have pending actions wait until there is a free slot (rather than drop them). I want to receive the ...
6
votes
3answers
77 views

Color-coded console output

I wrote this Console.Write function to use in my applications where I need to easily color-code output. Example syntax would be: ...
3
votes
1answer
97 views

Using composition instead of inheritance

I have been using Entity Framework 6, AutoMapper, ASP.NET Web Api and hit a few problems along the way, each time it was recommended that I could change my code from Inheritance to use composition ...
7
votes
0answers
82 views

Fun with CallerLineNumberAttribute: clever hack or terrible idea?

One fun feature that was added (fairly) recently in .NET is the [CallerLineNumber] attribute, which, in conjunction with ...
6
votes
4answers
111 views

C#/.Net 4.5 - Number Guessing Game

I'm currently enrolled in an introductory C#/.Net 4.5 course and one of the things I want to focus on is the quality of my code. This is the first assignment our instructor had us do, the ...
2
votes
1answer
22 views

Registering endpoints and HTTP method for exemption of authentication

Haven't used code review before, but figured I'd put this one out there. I have a set of API endpoints where the URL is not standardized, so I could either get "api/auth" or "api/auth/" (may or may ...
3
votes
1answer
37 views

Type Name or Alias via Reflection for TT Code Generation

I was working on some TT code generation to get rid of mundane C# codings in VS2013 Express Edition, and after researching online, created the following helper methods to facilitate Type declarations. ...
-1
votes
1answer
88 views

Using async & await

I've been experimenting with some old code that needs refactoring in places and was testing if there was any improvement to iis threads etc by uploading file asynchronously (Server Side). I'm using ...
0
votes
0answers
31 views

ControlContent navigation within wpf mvvm application

I have a wpf&&MVVM application, in which I have a problem in responsiveness: I have a ContentControl to be changed in the click into a menu In The view ...
2
votes
1answer
47 views

Shared access point

In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one ...
5
votes
1answer
55 views

Implementation of the FNV-1a hash algorithm for 128-, 256-, 512- and 1024-bit

A little over a year ago, I asked this question. Since then, I've implemented the larger bit variations and am looking for any and all feedback - performance is obviously key when talking about ...
6
votes
0answers
95 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 ...
3
votes
1answer
67 views

.Net BouncyCastle - CSR and Private Key Generation

The purpose of this code is to generate the CSR and the Private Key. The scenario is that we have some clients for whom we run websites and for the SSL component we want to have a page on our site ...
-4
votes
3answers
102 views

Application search form

I have a search form in my application. When I search, it takes too much time to retrieve and display data, so I need to optimize this code. ...
5
votes
2answers
107 views

Using Linq syntax, how can I remove the select n+1 issue in this method?

I have the following code in a validation module. It works the way I want it to, but it has an obvious select n+1 problem. I would like to refactor this code to make a single call to the db to perform ...
8
votes
3answers
144 views

Collection that can be modified in a foreach

Sometimes you want to add/remove items from a collection inside of a foreach loop. Since this isn't possible, a common pattern is to add the items to a separate ...
4
votes
2answers
56 views

Generic object pool class using Spinlock/Monitor

I've written the following object pool class, and because this is my first encounter with synchronization primitives, I need reinsurance from an expert that this code is safe. I've tested it myself ...
4
votes
1answer
185 views

Is this pattern of Task queueing acceptable?

The AsyncWorkerQueue class uses TPL Data Flow and Rx to async process and cancel work in a queue. It takes in a worker factory (Func) and executes it when its turn (or not if its scheduled to be ...
2
votes
1answer
64 views

Go through every pixel of an image and then dispose of it

I'm a little confused as to whether implementing the Dispose method serves a purpose in this code. It never gets referenced by any other class in my project, so ...
1
vote
1answer
92 views

Thread Safe Objects in CSharp - ConcurrentDictionary

I'm using ConcurrentDictionary to hold the records.. I'm reading files from the local system in parallel, to speed up the process. Sample 1: ...
1
vote
3answers
53 views

Initializing object by settings implemented as a class [closed]

Here is the story. We have the BankTerminalSettings class. It has many properties: ...
5
votes
2answers
93 views

Optimizing this method (HashSet.RemoveWhere performance issue)

I have the following method: ...
8
votes
4answers
123 views

Multiple 'using' statements in method implementation

I'm learning WebAPI framework for ASP.NET and C#. Is the following way of handling incoming data correct? ...
0
votes
1answer
97 views

XML document parser with XPath

Here is my simple implementation on XML parser for XML which I received from a server response. Also I've tried to use XmlPathDocument but failed to get child ...
4
votes
2answers
202 views

TCP chat application with both server and client logic in same application

Here is my simple chat program. I'm wondering whether it has an acceptable design (both object oriented design and network design). If you want to run it, I can provide the solution folder. ...
3
votes
1answer
76 views

Using list of tasks to obtain and cache data

I develop Windows Phone App with Prism framework (MVVM). I use data caching. To get data I use proxy service. Proxy service creates two ...
1
vote
2answers
70 views

Setting every element in an array to a given value

Given the length of an array and a char, I would like to replace every element in a char array with that given char. Using a ...
6
votes
1answer
105 views

A super string cleaner

I need a method that clean up a string considering these few rules: Remove or not Spaces Remove or not Special Chars Remove or not Numbers Descaptalize or not the string (this is don't really needed ...
7
votes
2answers
340 views

Which option is better for readability when dealing with blank strings?

I'm working off a specification that says a bunch of fields within a record (one record being one line) must be blank. For example, it says that chars 6-14 must be blank. I am building a class ...
6
votes
2answers
690 views

C# AES Encryption

I've been researching AES encryption a bit over the past several days. The official (MSDN) examples I've seen are encrypting and decrypting using the same AES instance. They don't go in to what to do ...
0
votes
4answers
108 views

Remove extra spaces from a string without using Regex or any internal library methods

The objective is to remove extra spaces from the below string: " Today it is going to rain. " so it looks like below ...
2
votes
1answer
41 views

Detecting the attachment of a DataContext

In our application the views and the viewmodels are created in parallel to increase the performance and when the viewmodel is created it is attached to the datacontext. While there is no datacontext ...
6
votes
1answer
129 views

RoundStack Implementation

I just recently made an attempt at implementing what I have been led to understand is called a RoundStack, simply meaning contrary to .NET Stack's default behavior ...
2
votes
1answer
72 views

A thread-safe initialization guard

I have written a type with the following public API: ...
3
votes
2answers
83 views

Communicating messages to objects

In my MUD game engine, I built a messaging api that allows objects to subscribe to concrete implementations of an IMessage interface. Is there anything glaringly ...
4
votes
2answers
231 views

Query results with many to many and some parameters using Entity Framework in a more efficiënt way

I've created a working query in Entity Framework and I'm curious if there's a better way to do this. Since there's a lot of field on my models, I will only publish the relevant ones here. My Models ...
4
votes
1answer
62 views

Executing a list of tasks from a database

I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly. Currently I have implemented this in the following way: ...
1
vote
1answer
142 views

IRepository Pattern - Interface Segregation Principle

I have an IRepository class that I use a lot. But I noticed that for many of my repositories I do not implement most of the methods. Also, I usually don't have a ...
2
votes
2answers
162 views

Timecode class design

I've created a Timecode class. The "timecode" that I'm trying to represent is a timecode that is used in video editing quite often, and is seen displayed in the ...
10
votes
2answers
495 views

Reusable Unit Of Work Interface / Factory

Given my IUnitOfWork interface using System; public interface IUnitOfWork : IDisposable { void Commit(); } I then ...
5
votes
1answer
198 views

Regex for matching a US phone number

I have written my first regex: ...
3
votes
3answers
90 views

Zero pad function trim extra leading zeros

Here is a zero pad function I have: ...
2
votes
5answers
205 views

IIF shortern to one datarow .Net

Is it possible to shorten the Isnull checking? It would be great to shorten this code and only have to put the datarow once. This code imports data details (usually there would be more .x = ...
3
votes
0answers
49 views

Calculate compilation time from AssemblyVersion attribute

In my program, I display the compilation time which is calculated from the AssemblyVersion attribute. The attribute is set to automatically generate a version ...
1
vote
1answer
344 views

Adapting C# 2.0 event code for C# 5.0

I came across this excellent post on delegates and event and tried to adapt it to C# 5.0L ...
1
vote
1answer
89 views
2
votes
2answers
74 views

Avoid Split to reduce memory press (on servers)

I have a Component that is used for all Active Directory queries. The function below is used heavily perhaps even milions of times each day. Performance is a feature! It's used on servers and I ...
3
votes
1answer
56 views

Conversion Helper with support for enumerations and Nullable<T> - The Remix

I recently wrote this code as a more versatile stand-in for Convert.ChangeType. I very recently posted an earlier version, for which I received some good feedback. I've incorporated that feedback and ...