C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
2
votes
1answer
26 views
What are the best practices with multithreading in C#?
For a while I have been interested in seeing if some tasks work well when split across multiple threads.
On the one project I have been busy with I have been creating a lot of small utility apps, to ...
2
votes
0answers
19 views
EF6-Lambda Expressions deep big-tree query
I am looking to improve the following query.
We are using EF6 (CodeFirst) and C# Lambda Expressions, and Repository/Unit of Work patterns. Also, we needed to restrict the query in a way that we ...
3
votes
4answers
192 views
2
votes
4answers
292 views
Silent Try_catch in high load socket server or not?
I'm working on a socket application that will listen to incoming messages from about 400 devices. They all send a message at least once per minute. Now I have a working program and it has been running ...
3
votes
1answer
56 views
Should I null coalesce EventArgs?
When I implement events, it usually looks something like this:
...
0
votes
1answer
45 views
Drawing multiple Images
Im trying to draw a lot of fields image for my world generation, all is perfect 64 fps, but if i began to draw all the time the grass it became laggy, like 59 fps (something that musn't happen! :( ), ...
4
votes
1answer
44 views
Message Based Communication Design
I'm trying to design an API.NET for some communication purposes with Testing Equipment and I cannot figure out a proper way for designing the architecture.
Basically, we have different (physical) ...
5
votes
1answer
35 views
Verifying the type of an AggregateException's inner exception in a unit test
I've got the following code inside an integration test.
...
3
votes
1answer
41 views
Unit of Work / Repository nHibernate
I have a Unit of Work / Repository pattern in place to abstract away some nHibernate. Most examples I've seen though use the pattern a little differently.
In ...
2
votes
1answer
31 views
Parsing ODataQueryOptions<T> to Expression<Func<T, bool>>
I am following up on this answer for a scenario that I am currently working on. Like the OP, I am too concerned about the longevity of the code.
...
3
votes
1answer
51 views
Method to return a string of max length (in bytes vs. characters)
In my (c#) code, I need to generate a string (from a longer string) which when UTF-8 encoded, is no longer than a given max length (in bytes).
...
0
votes
0answers
32 views
Advanced programming Advice to separate code for classes? [on hold]
Quick question, Now further in my career I have found that I am still sticking with some of my bad coding techniques, such as Coding directly into the Event (such as the _ButtonClick event), instead ...
6
votes
1answer
87 views
Abstract Factory Pattern C# Example
I am working through more tutorials on Design Patterns and came across the Abstract Factory Pattern. I extended it out a bit (the example that is) and want your opinion:
...
3
votes
0answers
31 views
PreWarmCache for MVC Application with Stopwatch Infinite Loop
I used the information from the article "Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series)" to create a background task that runs on an infinite loop. Ultimately, this program is going to ...
9
votes
1answer
352 views
Chunk Generation Performance in C#
I'm working on a game in C#, this game generate new chunk (infinite) when you move around. If I have > 1000 chunks in my list then it become laggy even though I only load the necessary chunks on my ...
6
votes
4answers
1k views
Regex validation for Email Address
I need to validate whether my regex is correct for below scenario. Suggestion's if the regex is correct:
Wiki Link Local_part
The local-part of the email address may use any of these ASCII ...
-1
votes
0answers
12 views
10
votes
3answers
675 views
Does everyone still love Fibonacci?
I'm following up on this question. I made a few decisions about my model and implemented recommendations accordingly.
TL;DR the link
Uses a loop algorithm to return a Fibonacci number \$Fn\$ of ...
3
votes
3answers
120 views
5
votes
1answer
37 views
Negative Lookbehind Regex
I have the following code which attempts to match all strings like "*SOMESTRING" (which can include numeric values), but not "*SOMESTRING*". For this I am using a negative lookahead as follows;...
3
votes
2answers
50 views
Find all file occurences of a search term on drive
I have written a small application that lets the user search drives for their given input string. I am only returning the full name of files. What I have now is the following method to retrieve those ...
20
votes
4answers
2k views
Everyone loves Fibonacci
I was bored and burnt out on more serious projects.... until I saw this Computerphile video on YouTube. Now I'm inspired again. Now I feel like spending some time implementing that recursive algorithm ...
2
votes
1answer
54 views
Cleaning User Input
I am not sure if I am approaching this task the correct way. I have a view model with multiple string properties. I pass the model through an interface to a service class that contains a void to ...
3
votes
3answers
58 views
Validating a string under few conditions
Following code validates NIC number of a person (National Identity Card, no like SSN)
Requirements are...
Length should be 10 digits or characters
All should be digits except the last one
Last one ...
0
votes
0answers
25 views
Using a single validation handler for all controllers in a form
In input validation I'm using this validation method in my all Forms. Here I have a single handler for all TextBoxes in my Form and if I have other controllers like ...
5
votes
2answers
56 views
Convert string to multiline text
I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
10
votes
1answer
125 views
Tweets per second, using linked list
This is a TalentBuddy Challenge
Your task is to
write a function that prints to the standard output (stdout) the highest number of tweets recorded between each second in the array and the past ...
9
votes
2answers
71 views
Extending database factory class to use auditing class
I'm the the process of adding change auditing to my existing DB class which encapsulates database calls.
Previously I would just pass in a ...
3
votes
4answers
138 views
Input validation for text boxes in a Form
In a Win Form I'm doing initial validation in the Form. So before saving data, I want to validate whether all the required fields are filled (Text Boxes) by the user. There are about 18 such Text ...
2
votes
1answer
50 views
4
votes
1answer
135 views
IndexOrDefault that functions like FirstOrDefault
I don't know why this is not in the .NET Library, but I need to be able to use an index against a list and not have it throw an exception if it is outside the bounds of the list.
This is what I came ...
2
votes
2answers
78 views
User Login Logic
I want to see if this is as streamlined as possible. Most of the logic is accomplished through methods in the model. The controller does one of four things:
redirects new users to registration
...
3
votes
1answer
72 views
Is this a good way to deal with this tricky generic situation?
I have a project which should be thought of split into two layers: an IO layer which consists of sensors (input) and effectors (output), and a core layer which contains logic for determining which ...
5
votes
3answers
260 views
How to increase performance/speed of code that uses .Count() on Lists?
The Test
PublicQuestion_ComplexTest
is taking around 1600ms (1.6 seconds) to run, but used to take 92ms. I have a feeling this is because of recent code changes ...
1
vote
1answer
21 views
Refactor Oracle Entity Framework lambda query
I had a ugly problem and wrote an ugly query.
Query creates a cache that is used to get person id when I have {full_name, id_code?, birth_date?}. By question mark I mean that it is perfectly valid ...
0
votes
0answers
8 views
InfoPath dropdown list in repeating section changed event modifies only the first row but not the newly created [closed]
favorite I have InfoPath form that has two dropdown lists with a datasource coming from same sharepoint list. One is getting code field and the other description field. I want when a user selects one ...
7
votes
2answers
191 views
Should I set a license in the constructor or a static constructor?
We are using the Aspose PDF library to work with PDF files. Aspose requires the license to be set once per process. Accordingly, I have created the following common static method that sets the ...
5
votes
4answers
152 views
Faster method to find data using search word?
I need to search through a string array to find every occurrence of "Parameters Table", and between each "Parameters Table" and the next, get another string from a specified index (that remains ...
2
votes
1answer
61 views
Calling a copy constructor in Presenter to prepare a list of Models
I'm new to MVP. In a presenter I have following code. Here what am I trying is to create a list of Model objects (in this case ...
5
votes
2answers
195 views
1
vote
1answer
42 views
Find part of string in array, replace entire row with that part of string if found
Following is the string: (I'm getting that from config file so its not constant):
...
1
vote
1answer
63 views
Async method with multiple tasks
I'm trying to make my ASP.net Web API methods asynchronous. This method is in the Business Logic layer of my N-tier. I'm waiting for the result from my 1st task and use it on the 2nd task, but I ...
7
votes
1answer
156 views
Unique key having length of 8
I have to generate the unique key having a length of 8, which should be comprised of some set of characters:
...
13
votes
2answers
195 views
Calculate the intersection between two intervals on the same circle
I want to calculate the ratio of intersection between two intervals; the length of the intersection divided by the length of the shorter interval.
If two intervals do not intersect, the ratio is 0. ...
3
votes
1answer
53 views
Exception handling with expression lambda in Presenter class
Following is a code snippet from MVP Win Forms application.
My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be ...
6
votes
1answer
70 views
Method to determine redirect after login
I have a method that returns a URL to send a user should they pass a login. My problem is two of these links are hard coded one of which is attempting to pass a variable to the model of that ...
2
votes
0answers
49 views
Possible memory leak with WPF Custom Control?
I might have a potential memory leak with my custom control. Do I actually have one?
...
4
votes
1answer
35 views
Follow Up post: Proper handling of exceptions in MVP
This is a follow up post of my early question "Proper handling of exceptions in MVP"
So based on the answers I re edited the post and now my exception handling code looks like this...
DAL
...
8
votes
4answers
467 views
Is this an efficient use of a boolean method?
This is sort of a follow up to a previous question (Do I have any SQL leaks?).
I have changed some things around and am working on a solution where I use Active Directory to gather information about ...
5
votes
4answers
161 views