.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

2
votes
0answers
35 views

Refreshing customer list periodically in the background

I have a method RefreshCustomersInternal that refreshes customer data from a server and returns a Task. Since this process is ...
15
votes
5answers
607 views

Populating a ListView with Items

I populate a ListView with Items. Each Item has data attached to its .Tag property. Over time, I have needed to handle many cases where something would be null or ...
2
votes
2answers
40 views

Using ActiveDirectoryMembershipProvider with ASP.Net Identity?

I was told in SO to bring this question here. So here goes - I am trying to learn how to use ASP.Net Identity. My scenario is that I have to authenticate against Active Directory. For that purpose I ...
2
votes
0answers
44 views

Rx.net File watcher

I am new with Rx.net and tried to do a folder watcher that could send a notification when a new file is done being uploaded. Each instance check one and only one folder. Here are the steps to achieve ...
4
votes
2answers
58 views

De-serializing and Serializing objects the proper way

I am serializing and de-serializing a class object within the class which is then sent over the network like this: ...
1
vote
2answers
102 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
93 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
67 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
2answers
83 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
105 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 ...
8
votes
1answer
107 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
5answers
140 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 ...
3
votes
2answers
36 views

Registering endpoints and HTTP method for exemption of authentication

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 not end with "/"). I'm 'registering' the endpoint, plus the HTTP Method ...
3
votes
1answer
57 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
114 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
40 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
48 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
67 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 ...
7
votes
2answers
152 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
96 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
107 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
110 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
153 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
68 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
194 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 ...
3
votes
1answer
73 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 ...
3
votes
2answers
114 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
55 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
103 views

Optimizing this method (HashSet.RemoveWhere performance issue)

I have the following method: ...
8
votes
4answers
135 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
117 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
322 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
88 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
75 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
112 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
342 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
1k 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
204 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
43 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
146 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
77 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
307 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
155 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
212 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 ...
11
votes
2answers
611 views

Reusable Unit Of Work Interface / Factory

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

Regex for matching a US phone number

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

Zero pad function trim extra leading zeros

Here is a zero pad function I have: ...
2
votes
5answers
214 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 = ...