Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:46:55+00:00 2026-06-17T10:46:55+00:00

Is .NET DateTime thread safe? I’m not worried if the read operation returns incorrect

  • 0

Is .NET DateTime thread safe? I’m not worried if the read operation returns incorrect value, my only concern is: will DateTime object get corrupted if not synchronized.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:46:56+00:00Added an answer on June 17, 2026 at 10:46 am

    Reads and writes to DateTime fields are not atomic (at least on 32 bit systems).

    • If you assign from multiple threads to the same property at the same time you can corrupt it.

    • If you read from one thread, and write from another, the reading thread might get corrupted values.

    • Reading from multiple threads while having no writing threads at the same time is safe.

    Essentially the two 32 bit halves of a DateTime might contain values of different age when used from multiple threads at the same time.

    You can get a mix of two writes. The high 32 bit part of one write, and the low 32 bit part of another write.

    As an alternative you can use an Int64 for the field, and work on it with atomic methods from Thread and Interlocked. Then use new DateTime(ticks) and dateTime.Ticks to convert to/from DateTime.

    MSDN says:

    All members of this type are thread safe. Members that appear to modify instance state actually return a new instance initialized with the new value. As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.

    Assigning an instance of this type is not thread safe on all hardware platforms because the binary representation of that instance might be too large to assign in a single atomic operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to serialize a .NET DateTime value in a protocol buffers message. My
Question from beginner. Why code <%= System.DateTime.Now.ToLongDateString() %> is not executed in ASP.NET. Could
In earlier vb.net 2008 I used the DateTime to read the date in dd/mm/yy
Using C# .NET 3.5. It seems I'm not the only one, since a search
Possible Duplicate: Converting .NET DateTime to JSON How can I convert a date value
From another answer on Stackoverflow is a conversion from Javascript date to .net DateTime:
In the .Net framework DateTime structure, the Year is defined as an int (which
I'm calling .NET's DateTime.ParseExact with a custom format string along the lines of MM/dd/yyyy
net I am trying to take a value from a previous form typically in
if i run Server App. Exception occurs: on Dinle.Start() System.Net.SocketException - Only one usage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.