.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
0answers
15 views

Completed WorkItem List population [on hold]

I have a program where we schedule work items in a queue and process them in background thread one-by-one and load completed work item into a list. Below is code to schedule work item. ...
3
votes
0answers
137 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
39 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
62 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
48 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
73 views

Optimizing this method (HashSet.RemoveWhere performance issue)

I have the following method: ...
8
votes
4answers
111 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
67 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
97 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
54 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
59 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
82 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
335 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
237 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
48 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
38 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
116 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
54 views

A thread-safe initialization guard

I have written a type with the following public API: ...
3
votes
2answers
79 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
140 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
57 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
112 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
107 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
324 views

Reusable Unit Of Work Interface / Factory

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

Regex for matching a US phone number

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

Zero pad function trim extra leading zeros

Here is a zero pad function I have: ...
2
votes
5answers
188 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
43 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
332 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
77 views
2
votes
2answers
71 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
53 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 ...
3
votes
3answers
98 views

LINQ foreach - error handling and general improvement

I'm looking for two kinds of feedback: Is there a better way of doing what I'm attempting to do? Any obvious weaknesses that could potentially cause problems? The code in question (I've broken it ...
2
votes
1answer
79 views

Checking if a directory exists in FTP without relying on exception handling?

I've written a method to check if a directory already exists on an FTP server. The only way I could see to make this work was to return a different result from the method if an exception is thrown - ...
5
votes
3answers
102 views

Conversion helper with support for enumerations and Nullable<T>

I recently wrote this code as a more versatile stand-in for Convert.ChangeType. I have a nagging feeling that there's something I might be overlooking, or that ...
3
votes
1answer
65 views

Event Subscriber with Parallelism

I am trying to exploit asynchronism for parallelism. This is my first attempt at a parallel event subscriber. In your expert opinions, is this a valid approach? ...
-4
votes
1answer
64 views

Declaring the reference of an object within a for loop [closed]

Please let me know which approach is better and why. Is it better to initialize the variable outside of the loop, or inside? Case 1: ...
3
votes
1answer
52 views

Invoking only the last registered event handler

We are building a game and we have a dialog system. Dialogs may open and stack on top of one another. When every dialog opens, it registers itself to handle the BackButtonPressed event: ...
14
votes
9answers
654 views

How can I refactor to avoid repetition finding the index of strings in a list?

I have a list of strings where I want to find the index of a first- and second-choice video compressor. Logic: If the first choice is available, return its index. If not, and the second choice is ...
2
votes
2answers
119 views

Streamreader file.Readline properly closing the stream

Is this OK? (.Net 4.5) ...
7
votes
1answer
491 views

Math expression parser in C#

EDIT: Added refactored version 2.0 to the end! I have a parser that is supposed to take a string similar to a math expression and return a Tuple of: An array of strings where each string ...
11
votes
1answer
137 views

Change desktop background [duplicate]

I've created a simple program that downloads an image (different image every day), then sets it as my desktop background. It is a console application, and closes immediately after downloading the ...
4
votes
3answers
121 views

Make huge view in C# readable and maintanable

I have an application that is using MVC5 with C# and Razor Engine. This view displays a huge table: ...
1
vote
2answers
173 views

Producer Consumer in C# with multiple (parallel) consumers and no TPL Dataflow [closed]

I am trying to implement producer/consumer pattern with multiple or parallel consumers. I did an implementation but I would like to know how good it is. Can somebody do better? Can any of you spot ...
4
votes
2answers
442 views

Speeding up Parallel.ForEach iterating through datatable and rendering report

I am attempting to speed up the processing of 5000 rows received from the database, which I then render as a crystal report, export to a byte stream and save in a database table. Currently I am using ...
4
votes
1answer
176 views

Asynchronously wait for a task to complete and do some async action while waiting

I have a long-running task. My goal is to create a method that will allow me to: Asynchronously wait for this task to complete While waiting on a task, do some async action once in a while. This ...
0
votes
1answer
116 views

Seekable HTTP Range Stream

I read around for a while and surprisingly didn't find a fitting solution. I need a .NET Stream that internally issues HTTP Range requests when it seeks. There are huge files server-side for which I ...
2
votes
1answer
120 views

Is this the correct usage of ConcurrentDictionary<TKey, TValue>?

I need to make a simple class that tracks how many clients are listening to a specific item, will be referred to as building hence forth. I will have a timer running that will check which buildings ...
4
votes
2answers
362 views

Get missing sequential numbers from array

I have an array like Original = {1, 2, 3, 6, 7, 8, 9, 10, 12}. After removing some elements like Delete = {6, 7} from it, I want ...
0
votes
2answers
479 views

Connecting to a MySQL database with C#

Can anyone help me with checking this code? It is for connecting to a database. The method getFromDatabase is to take values from the database and put it to a ...