Magnus Mårtensson
Microsoft Regional Director, Azure MVP, CEO Loftysoft
Avirag Jain
Director & CTO R Systems
Mahesh Chand
Founder C# Corner, CEO Mindcracker
Chris Gali
CEO & Co-Founder Graphite
Subinder Khurana
Chief Architect StoryProcess, Founder NASSCOM DeepTech Club
Bryan Rishforth
Investor, Chairman Graphite
Bryn Everson
Director Biz Dev Graphite
Raj Tiwari
Digital Transformation Leader, Futurist and Visionary
Joseph Guadagno
Microsoft MVP, Lead Quicken Loans
Nikita Sachdev
Entrepreneur, Blockchain Enthusiast & Advisor, Social Media Influencer
Doug Wagner
COO & Founder Adapt Technical Group
Ritesh Modi
Architect, Senior Evangelist, Cloud Architect
Crystal Wenrick
Director Communications Mindcracker
Allen O’Neill
Microsoft MVP, Consulting Engineer/Architect
Praveen Kumar
CEO MCN Solutions
Chris Love
Founder Love2Dev, Microsoft MVP, Author
Sanjay Vyas
Microsoft Regional Director, Microsoft MVP, Founder & CEO SkillLabs Technologies
Veena Sarda
Deep Learning Consultant, Author
Sekhar Srinivasan
C# Corner MVP, Microsoft Certified Trainer, Pluralsight Author
Lalit Bansal
Founder & CEO - EIY SYS
Navdeep Garg
CEO Revinfotech
Prakash Tripathi
Tech Manager/Leader, Microsoft MVP, Blogger
Bhavna Jain
Breakthrough Consultant
Naveen Sharma
Enterprise Architect, Leadership Coach, Author
Vidya Vrat Agarwal
Principal Architect, Microsoft MVP, Author
Sheetal Agarwal
Founder Clownselors, Medical Clown, Trainer
Abhishek Kant
Founder GTM Catalyst
Vishnu Saran
Founder & CEO VoiceQube
Sandeep Soni
Founder & CEO Deccansoft, Microsoft Certified Trainer
Parveen Malik
AVP InfoSec & Vulnerability Management, Information Security Expert
Nitin Pandit
Microsoft MVP, Developer Evangelist, Author
Niloshima Srivastava
C# Corner MVP, Tech Architect, Trainer, Blogger
Bala Chirtsabesan
Senior Software Engineer at Microsoft, Author
Manoj Mittal
Sr. Technical Architect, C# Corner MVP, Author
Chandni Di
Co-Founder Voice of Slum
Vithal Wadje
Technical Lead, Microsoft MVP, Author
Shivam Ahuja
Founder SkillCircle, Business Mentor
Chervine Bhiwoo
Solution Architect, Microsoft MVP, Author
Saurabh Jain
Vice President Paytm, Founder Fun2Do Labs, Author
Vinay Solanki
Head IoT at Lenovo, Founder IoT-NCR
Anshu kumari
Founder Blockchainkids, Inventor, Trainer
Amit Singal
CEO Startup Buddy
Dev Pratap
Co-Founder & CEO Voice of Slum
Amey Vartak
Technology Consultant, Full Stack Developer, C# Corner MVP, Author
Viswanatha Swamy
Principal Software Engineer, C# Corner MVP, Author
Sanket Verma
Research Engineer @ Ballistics (Forensics) and Chair, PyData Delhi
Sourabh Somani
Lead Developer, Microsoft MVP, Author
Abhishek Mishra
Software Architect, C# Corner MVP, Author
Siddharth Vaghasia
Technical Consultant, C# Corner MVP, Blogger
Bassam Alugili
Senior Software Specialist, Database Expert
S Ravi Kumar
Solution Architect, C# Corner MVP, Author
Sundaram Subramanian
Full Stack Developer, C# Corner MVP, Speaker
Deepesh Somani
Solution Architect, Microsoft MVP, Author
Debasis Saha
Technical Project Manager, C# Corner MVP, Blogger, Author
Vipul Jain
Software Architect, C# Corner MVP, Author
Akshay Patel
Technical Architect, Microsoft Certified Trainer, C# Corner MVP, Author
Stephen Simon
RPA Developer, Evangelist, Author
Vivek Sharma
Founder Kingster636, AR/VR Specialist
Jeetendra Gund
Technical Lead, C# Corner MVP, Author
Sujal Beniwal
AI Enthusiast, Student
M Viknaraj
Microsoft MVP, Azure Architect, Author
Prasham Sabadra
Software Architect, C# Corner MVP, Trainer, Author
Aakash Maurya
Senior Developer, C# Corner MVP, Speaker
Ankit Sharma
Senior Software Engineer, C# Corner MVP, Author
Mangesh Gaherwar
Team Lead, C# Corner MVP, Author
Viral Jain
Technical Consultant, C# Corner MVP, Author
Bhasker Das
Solution Architect, Evangelist
Manish Dwivedi
Associate Project Manager
Ck Nitin
Programmer, Author
Rohit Gupta
Technical Trainer, Author
Manish Tewatia
Full-stack Marketer, UX Designer
Bhavya Gaur
Technical Illustrator
Rohit Tomar
SEO/SMO Expert
Web Track
Cloud & Data Track
Dev Track
Registration & Breakfast
Future of Desktop Apps with JS (ElectronJs)
Nitin Pandit
Building Serverless Microservices Using Microsoft Azure
Vithal Wadje
Innovating RPA: A Robot for Every Person
Stephen Simon
Managing Cloud Storage Accounts using Logic Apps
Viknaraj Manogararajah
Data visualization using Python
Sekhar Srinivasan
Going Cross platform with AR Foundation
Vivek Sharma
Keynote
Managing your Azure dependencies in ASP.NET Core apps using VS
Bala Chirtsabesan
Securing Applications on Intelligent Azure
Abhishek Mishra
Getting started with Blazor the Framework of Future
S Ravi Kumar
Lunch
Build Progressive Web Apps using Angular 9
Debasis Saha
Build and deploy to any platform using Azure DevOps
Chervine Bhiwoo
Deep Dive in Azure Service Bus
Akshay Patel
Build a Native Mobile Application using React Native and JavaScript
Joseph Guadagno
Making sense of Web Job, Web Job SDK and Functions in Azure
Prakash Tripathi
CloudFront Distribution in AWS
Viral Jain
Tea Break
Introduction to PowerBI
Aakash Maurya
Build Advanced SPFx solutions with React and Graph API
Siddharth Vaghasia
Build Business Intelligence Analyst (BIA) Skills
Sundaram Subramanian
Deep dive of Power Platform – AI BUILDER
Prasham Sabadra
Panel 1
What's new in SharePoint development
Vipul Jain
Build a SSO (Single Sign On) based Native JavaScript application with Microsoft Identity within 10 minutes
Manoj Mittal
Panel 2
Applications and working of AI
Veena Sarda
Deploying serverless API's with .Net core 3.0 on AWS & Azure
Amey Vartak
Panel 3
Blockchain with .NET Core (Ark)
Anshu Kumari
Closing Note & Prize Distribution
Dev Track
Cloud Track
Architecture Track
Emerging Tech Track
Registration & Breakfast
Creating Full-Stack Web Apps Using Server-Side Blazor
Ankit Sharma
Real time face recognition with MS Cognitive Services
Niloshima Srivastava
Building Scalable APIs with GraphQL
Jeetendra Gund
Future of development with AI and Blockchain
Navdeep Garg
Debugging Tips and Tricks with Visual Studio 2019
Joseph Guadagno
Azure Containers
Abhishek Kant
Enterprise Architecture
Naveen Sharma
Bot Framework - learn it fast and look like a boss!
Allen O’Neill
Keynote
.Net Core & C# 8 Performance
David McCarter
Working with Azure kubernetes services
Ritesh Modi
Becoming an Architect
Vidyavrat Agarwal
Why Techies Need to Learn Product Management
Saurabh Jain
Lunch
Build a rules engine in .Net Core
Sanjay Vyas
Building CI and CD Pipeline using Azure DevOps
Sandeep Soni
Entity Framework Core - Tips and Tricks, Performance Optimization, and Tuning
Bassam Alugili
Hacking your way into Data Science
Sanket Verma
Speed up your .Net Core Website
Sourabh Somani
Azure
Magnus Mårtensson
Demystifying Open Distro for Elasticsearch
Suman Debnath
Future of Data
Shivam Ahuja
Tea Break
gRPC with C# and .Net Core
Mangesh Gaherwar
Panel 1
Essentials of Cloud security
Parveen Malik
Power platform and Dynamics 365
Deepesh Somani
Microservices - the gRPC Way
Viswanatha Swamy
Panel 2
Reserved
Reserved
Closing Note & Prize Distribution
Handling concurrency safely in modern C#
Concurrency is rarely a single-feature concern for C# teams. At the C# Corner Annual Conference 2020, cloud, data and DevOps sessions all assume that requests, jobs and background workers may touch shared state together. A web API can serve customers in Sydney while reconciliation work scans the same records. The goal is not to remove parallelism; it is to ensure each shared-state transition has a clear, testable guarantee.
ConcurrentDictionary and locks solve related but different problems. ConcurrentDictionary protects the container’s individual operations, while a lock can extend exclusion across several reads and writes. Neither automatically makes a multi-step business rule atomic. If code checks an account balance, calculates a new value and later stores it, another thread can intervene between those steps. Design must begin by defining the smallest operation that must look indivisible to other callers.
This matters across Australia’s technology market. Sydney and Melbourne are major hubs for fintech, commerce and SaaS, where bursty traffic makes contention testing routine. Many Australian organisations maintain established .NET and Microsoft Azure estates, including public-sector systems in Canberra, where maintainability and predictable behaviour carry commercial weight. Local communication is often friendly and direct: “have a go” can mean try an approach, but design notes should still state exactly what is guaranteed.
A practical starting point is to use ConcurrentDictionary for independent keys, a dedicated lock for a small multi-field invariant, and immutable snapshots when readers need a stable view. The comparison early in this article offers a decision point; later sections address factory retries, deadlocks, async boundaries and production testing. Correctness should be judged by the contract seen by callers, not by whichever primitive posts the best benchmark.
Why shared state needs a different mental model
Thread safety is only the first layer. ConcurrentDictionary guarantees that its basic operations will not corrupt internal state under concurrent calls. It does not promise that Get, calculate and Set behave as one transaction. A Dictionary protected by a lock is safe only when every access uses the same gate and the critical section is short. A read outside that gate remains a data race even if every write is properly locked.
| Approach | What it protects | Multi-step consistency | Typical use |
|---|---|---|---|
ConcurrentDictionary<TKey, TValue> |
Individual dictionary operations | No arbitrary transaction | Independent high-contention keys |
Dictionary with a lock |
All accesses using the same gate | Possible within the critical section | Small, shared invariants |
| Immutable snapshot with atomic publication | Stable state visible to readers | Achieved through compare-and-swap | Configuration and derived indexes |
Race conditions often appear as duplicate work rather than visible corruption. Two callers may both miss a cache entry, both call an expensive service and then both attempt to add a result. ConcurrentDictionary accepts that pattern without damaging itself, yet only one value is stored. The same issue occurs when a value factory sends an invoice, increments a business counter or writes to an audit stream: the container cannot undo those side effects.
Other failures arise from assumptions about ordering. A caller may observe an older value after a newer one, enumerating keys may not match application-level expectations, and a blocked lock can reduce throughput. Thread-safe code can therefore still produce incorrect business outcomes. Tests must assert ordering and atomicity requirements explicitly, not merely confirm that the collection did not throw.
Using ConcurrentDictionary without accidental races
ConcurrentDictionary offers TryAdd, TryGetValue, TryUpdate, TryRemove, AddOrUpdate and GetOrAdd. These methods suit workloads where each key is an independent unit of work, such as session records, cached responses or per-tenant counters. They also provide compare-and-swap behaviour through TryUpdate, which compares the stored value before replacing it. Keep values immutable when possible; otherwise code holding a reference can mutate an object without changing the dictionary’s reference.
GetOrAdd can look atomic, but its value factory may run more than once when callers contend for the same absent key. For example, _accounts.GetOrAdd(id, key => CreateAccount(key)) may create several candidate accounts, although only one value is stored. Treat the factory as a pure calculation with no observable side effects. If loading a profile starts an HTTP request, cache the resulting immutable profile instead of performing billing or sending notifications inside the factory.
For counters, use a retry loop with TryGetValue, TryUpdate and TryAdd rather than a non-atomic read and write. Read the current value, attempt to replace it only if it has not changed, and retry when the comparison fails. AddOrUpdate is convenient for derived values, but its update factory can also execute multiple times, so it must remain side-effect free. This distinction prevents duplicate increments from appearing correct in a single-threaded test.
Applying locks with a deliberately small scope
A lock is appropriate when one operation must inspect and change several fields consistently. Protect a plain Dictionary with a private object, and use that same gate for every read and write: private readonly object _gate = new();. Never lock on this, a string, a boxed value or a shared type object, because other code can use the same instance. Keep the critical section small and avoid calling unknown external code while holding it.
Monitor locks are thread-affine and reentrant on the same thread. They must not be held across an await, and code entered on one thread must not be exited on another. Nested locks create another hazard: if one path locks A then B while another locks B then A, deadlock follows. Establish a global lock order or replace nested exclusion with one coordinator lock, a message-driven actor, or a database transaction.
Striped locking can reduce contention when many keys need occasional multi-step updates. A stable hash selects one of several gates, so unrelated keys can proceed independently. Hash collisions are safe for correctness, although colliding keys share a gate and wait together. Every access to a logical key must use the same stripe, while updates spanning keys need a common coordinator. A partitioned owner or serial queue is often clearer than maintaining a complicated lock hierarchy.
Making compound operations atomic
Consider a transfer that checks available funds, debits one account and credits another. Locking each account separately prevents corruption but does not make the transfer indivisible, and opposite update orders can deadlock. Choose a contract deliberately: one lock around the aggregate, a transactional ledger, or an idempotent command handled by a single owner. The important measure is whether observers can see a half-completed transfer, not how many individual writes occurred.
An immutable snapshot offers another model. Build a new map from the current one, publish it with Interlocked.CompareExchange, and retry if another writer changed the reference first. Readers can use a stable published map without taking a lock, while a writer serialises its read-compute-publish cycle. This works well for whole-state configuration and derived indexes. It costs additional allocation and still needs care when the rule spans several values.
A related .NET example, the graph recommendation pipeline, shows how graph-oriented services can combine shared caches with fan-out requests while keeping consistency boundaries explicit. The same rule applies to concurrent graphs: a cached neighbour list may be independently replaceable, but an operation that must preserve relationships across nodes needs one atomic boundary or an explicitly versioned design.
Designing async and cancellation boundaries
Async code needs different coordination. C# does not permit an await inside a lock, and Monitor cannot provide safe mutual exclusion across suspension points. When serialised asynchronous work is genuinely required, use SemaphoreSlim: await WaitAsync with a cancellation token, perform the operation, and release in a finally block only after acquisition succeeds. For independent keys, ConcurrentDictionary usually avoids the queueing and reduced parallelism introduced by a semaphore.
Cached tasks require special care. If the dictionary stores Task<T>, a GetOrAdd factory can still start several remote calls before one result wins. A Lazy<Task<T>> with ExecutionAndPublication can enforce single execution, although cancellation by one waiter must not accidentally cancel the shared operation. Define whether callers cancel independently, share a timeout, or receive a stale cached result, then encode that policy in the cache rather than relying on incidental task behaviour.
Bound work instead of allowing a traffic spike to create unlimited background tasks. Channels and dedicated consumers provide backpressure, while timeouts and idempotency keys make retries safe. Teams spread across Sydney, Brisbane and Perth often operate in follow-the-sun support windows, so timestamps, business-day rules and token lifetimes should use explicit time zones rather than a developer’s local clock.
Testing and operating concurrent systems in Australia
Concurrency controls also have a process boundary. ConcurrentDictionary and lock protect objects inside one application instance, not a fleet of Azure deployments. Use database constraints, row versions, idempotency keys or an established coordination service when correctness spans replicas. Avoid inventing a distributed lock from timestamps alone. For Canberra public-sector workloads, auditability, supportability and clear recovery procedures can carry more weight than a small latency gain.
Perth mining and energy systems add another Australian operating reality: field sites can work with intermittent links and delayed synchronisation. Make retries idempotent, distinguish authoritative writes from cacheable reads, and decide whether stale data is acceptable before the system is deployed. A timeout is not proof that an operation failed remotely; the retry path must not repeat a debit, create duplicate maintenance work or send another alert.
Test with real contention rather than only sequential unit tests. Use barriers or controlled tasks to force competing readers and writers, repeat the scenario enough times to expose rare interleavings, and assert business invariants after each batch. Monitor lock wait time, retry counts, queue depth, duplicate factory executions and error rates in production. The strongest design is the one whose guarantees remain clear when requests fail, replicas restart and teams in another Australian office inherit it.
1, CBD, Maharaj Surajmal Road, Near Yamuna Sports Complex, Delhi, 110032
GENERAL QUERIES
Manish Tewatia
manish@csharpcon.com
+91-9718-431-042
TICKET QUERIES
Atul Gupta
conference@csharpcon.com
+91-9910-125-804