Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access

Category: C#

C#

List.ForEach Hides Exceptions

- 05.01.26 - ErcanOPAK comment on List.ForEach Hides Exceptions

Errors vanish. WhyExceptions thrown inside delegates are harder to trace. Fix Use explicit loops for critical logic.

Read More
C#

Task.Run Inside ASP.NET Core Hurts Scalability

- 05.01.26 - ErcanOPAK comment on Task.Run Inside ASP.NET Core Hurts Scalability

Seems async, kills throughput. WhyConsumes thread pool threads. Fix Use async APIs instead of offloading.

Read More
C#

IEnumerable Executes More Than Once

- 04.01.26 - ErcanOPAK comment on IEnumerable Executes More Than Once

Unexpected duplicate work. WhyDeferred execution. Fix var data = query.ToList();  

Read More
C#

Boxing Happens Without You Noticing

- 04.01.26 - ErcanOPAK comment on Boxing Happens Without You Noticing

Performance drops mysteriously. WhyInterfaces cause value types to box. Fix Use generics to avoid boxing.

Read More
C# / Development

async void Swallows Exceptions

- 04.01.26 - ErcanOPAK comment on async void Swallows Exceptions

Errors disappear. Whyasync void cannot be awaited. Fix async Task MethodAsync()  

Read More
Asp.Net Core / C#

ASP.NET Core Thread Pool Starves Under Load

- 04.01.26 - ErcanOPAK comment on ASP.NET Core Thread Pool Starves Under Load

Requests queue endlessly. WhyLong-running sync tasks block threads. Fix await Task.Run(LongRunningWork);  

Read More
C#

DateTime.Now Breaks Distributed Logic

- 03.01.26 | 03.01.26 - ErcanOPAK comment on DateTime.Now Breaks Distributed Logic

Same code, different results. WhyLocal time zones and daylight saving. Fix DateTimeOffset.UtcNow   🔥 Why DateTime.Now Breaks Distributed Logic (And What to Use Instead) Same code. Different results.If you’ve ever seen time-based logic randomly fail in production, DateTime.Now might be the silent culprit. In distributed systems, local time is a trap. 🚨 The Core Problem […]

Read More
C#

LINQ Looks Clean but Allocates Heavily

- 03.01.26 - ErcanOPAK comment on LINQ Looks Clean but Allocates Heavily

Readable code, hidden cost. WhyMultiple enumerations. Fix var list = items.ToList();  

Read More
C#

Async Methods Still Block the Thread Pool

- 03.01.26 - ErcanOPAK comment on Async Methods Still Block the Thread Pool

Looks async, behaves sync. WhyCPU-bound work inside async methods. Fix await Task.Run(Compute);  

Read More
Asp.Net Core / C#

ASP.NET Core Memory Usage Keeps Growing

- 03.01.26 - ErcanOPAK comment on ASP.NET Core Memory Usage Keeps Growing

GC runs, memory stays high. WhyObject pooling misused or ignored. Fix services.AddPooledDbContextFactory<AppDbContext>();  

Read More
C#

Exceptions Used for Control Flow

- 03.01.26 - ErcanOPAK comment on Exceptions Used for Control Flow

Works until scale. WhyExceptions are expensive. Fix if (!TryParse(…)) return;  

Read More
C#

Events Cause Memory Leaks

- 03.01.26 - ErcanOPAK comment on Events Cause Memory Leaks

Even in managed code. WhyUnsubscribed event handlers. FixAlways unsubscribe or use weak events.

Read More
C#

Structs Can Be Slower Than Classes

- 03.01.26 - ErcanOPAK comment on Structs Can Be Slower Than Classes

Surprising but true. WhyLarge structs copied by value. Fix void Process(in MyStruct data)  

Read More
Asp.Net Core / C#

ASP.NET Core Requests Hang Under Load

- 03.01.26 - ErcanOPAK comment on ASP.NET Core Requests Hang Under Load

CPU low, threads exhausted. WhyBlocking calls inside async pipeline. Fix await SomeAsyncMethod();  

Read More
C#

Exceptions Used for Flow Control

- 02.01.26 - ErcanOPAK comment on Exceptions Used for Flow Control

Works… until scale. WhyExceptions are expensive. Fix Use Try-patterns instead.

Read More
C#

LINQ Causing Hidden Allocations

- 02.01.26 - ErcanOPAK comment on LINQ Causing Hidden Allocations

Clean code, slow runtime. WhyDeferred execution + boxing. Fix Materialize once when needed.

Read More
C#

C# Async Methods Still Block Threads

- 02.01.26 - ErcanOPAK comment on C# Async Methods Still Block Threads

Looks async, isn’t. WhyCPU-bound work inside async. Fix Offload CPU work explicitly. await Task.Run(() => HeavyCalculation());  

Read More
C#

Events Can Cause Memory Leaks

- 01.01.26 - ErcanOPAK comment on Events Can Cause Memory Leaks

Even in managed code. Why it happensUnsubscribed event handlers. FixAlways unsubscribe or use weak events.

Read More
C#

DateTime.Now Can Break Distributed Systems

- 01.01.26 - ErcanOPAK comment on DateTime.Now Can Break Distributed Systems

Time is harder than it looks. Why it happensTime zones + daylight saving. FixUse DateTimeOffset.UtcNow.

Read More
C#

C# Value Types Copied More Than You Think

- 01.01.26 - ErcanOPAK comment on C# Value Types Copied More Than You Think

Structs aren’t always faster. Why it happensLarge structs passed by value. FixUse in parameters.

Read More
C#

C# — GC.Collect() Hurts More Than It Helps

- 31.12.25 - ErcanOPAK comment on C# — GC.Collect() Hurts More Than It Helps

Manual GC kills performance. Rule Let the runtime decide.

Read More
C#

C# — async void Event Handlers Swallow Exceptions

- 31.12.25 - ErcanOPAK comment on C# — async void Event Handlers Swallow Exceptions

Crashes disappear silently. Fix Wrap logic with try/catch and logging.

Read More
C#

C# — Equals Without Operator Overload Is Inconsistent

- 31.12.25 - ErcanOPAK comment on C# — Equals Without Operator Overload Is Inconsistent

== and Equals() behave differently. Fix Override both consistently.

Read More
C#

C# — Stopwatch Is More Accurate Than DateTime

- 30.12.25 - ErcanOPAK comment on C# — Stopwatch Is More Accurate Than DateTime

Measuring performance with DateTime lies. âś… Fix Stopwatch sw = Stopwatch.StartNew();  

Read More
C#

C# — async Lambdas Capture Variables Unexpectedly

- 30.12.25 - ErcanOPAK comment on C# — async Lambdas Capture Variables Unexpectedly

Loop variables are captured by reference. ❌ Bug Perfectly compiled, logically broken code. ✅ Fix Create a local copy inside the loop.

Read More
C#

C# — string.Equals() Without ComparisonType Is a Bug

- 30.12.25 | 30.12.25 - ErcanOPAK comment on C# — string.Equals() Without ComparisonType Is a Bug

Default comparison is culture-sensitive. string.Equals(a, b) ❌ Risk Unexpected results in different locales. âś… Fix string.Equals(a, b, StringComparison.Ordinal)  

Read More
Applications / C# / Software

Prayer Times App v1.0.2

- 30.12.25 | 14.01.26 - ErcanOPAK comment on Prayer Times App v1.0.2

🕌 Modern, User-Friendly Prayer Times Application Completely free, portable prayer times application for Windows — no installation required. Supports 203 countries and 4,120+ cities worldwide. ✨ Features 🌍 Global Support: 203 countries, 4,120+ cities worldwide 🇹🇷 🇬🇧 Bilingual: Turkish and English interface ⏰ Smart Notifications: 5-minute and 1-minute advance warnings 🔇 Auto Volume Control: Automatically […]

Read More
C# / Uygulamalar / Yazılım

Namaz Vakitleri Uygulaması v1.0.2

- 30.12.25 | 14.01.26 - ErcanOPAK comment on Namaz Vakitleri Uygulaması v1.0.2

🕌 Modern, Kullanıcı Dostu Namaz Vakitleri Uygulaması Windows için tamamen ĂĽcretsiz, kurulum gerektirmeyen (portable) namaz vakitleri uygulaması. DĂĽnya genelinde 203 ĂĽlke ve 4,120+ Ĺźehri destekliyor. ✨ Ă–zellikler 🌍 KĂĽresel Destek: 203 ĂĽlke, 4,120+ Ĺźehir, TĂĽrkiye’nin tĂĽm il ve ilçeleri 🇹🇷 🇬🇧 Çift Dil: TĂĽrkçe ve İngilizce arayĂĽz ⏰ Akıllı Bildirimler: 5 dakika ve 1 dakika […]

Read More
C#

C# — List.ForEach() Is Slower Than foreach

- 29.12.25 - ErcanOPAK comment on C# — List.ForEach() Is Slower Than foreach

It allocates a delegate and blocks break/continue. âś… Prefer foreach (var item in list) { }  

Read More
C#

C# — DateTimeKind.Unspecified Breaks Serialization

- 29.12.25 - ErcanOPAK comment on C# — DateTimeKind.Unspecified Breaks Serialization

Unspecified kind leads to wrong conversions. âś… Rule Always specify: DateTime.SpecifyKind(date, DateTimeKind.Utc)  

Read More
Page 2 of 9
« Previous 1 2 3 4 5 6 7 … 9 Next »

Posts navigation

Older posts
Newer posts
January 2026
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Dec    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (923)
  • How to add default value for Entity Framework migrations for DateTime and Bool (814)
  • Get the First and Last Word from a String or Sentence in SQL (808)
  • How to select distinct rows in a datatable in C# (784)
  • How to make theater mode the default for Youtube (664)
  • Add Constraint to SQL Table to ensure email contains @ (561)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (544)
  • Average of all values in a column that are not zero in SQL (510)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (460)
  • Find numbers with more than two decimal places in SQL (427)

Recent Posts

  • C# Value Types Copied More Than You Think
  • C# Async Void Is Dangerous
  • C# Foreach vs For Performance Difference
  • SQL Deletes Lock Tables
  • SQL Queries Slow Despite Indexes
  • .NET Core APIs Feel Slow Under Load
  • ASP.NET Core Memory Grows Slowly
  • Git Conflicts Keep Reappearing
  • Git Rebase Feels Dangerous
  • Ajax Forms Submit Twice

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (923)
  • How to add default value for Entity Framework migrations for DateTime and Bool (814)
  • Get the First and Last Word from a String or Sentence in SQL (808)
  • How to select distinct rows in a datatable in C# (784)
  • How to make theater mode the default for Youtube (664)

Recent Posts

  • C# Value Types Copied More Than You Think
  • C# Async Void Is Dangerous
  • C# Foreach vs For Performance Difference
  • SQL Deletes Lock Tables
  • SQL Queries Slow Despite Indexes

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com