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

  • SEARCH
  • Home
  • 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 7895443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:38:42+00:00 2026-06-03T07:38:42+00:00

I am facing this strange problem with strings. I assigned a string like this:

  • 0

I am facing this strange problem with strings.

I assigned a string like this:

string temp = DateTime.UtcNow.ToString("s");
_snapShotTime = string.Copy(temp);

//here threads started....
//while thread progressing I am passing  _snapShotTime to create a directory.
//same in second threads.

But the time of local private variable _snapShotTime is keep on changing. I don’t know why. I have used a local variable and copy value in it.

Thanks

  • 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-03T07:38:43+00:00Added an answer on June 3, 2026 at 7:38 am

    I suspect your thread uses a lambda expression (or anonymous function) which captures _snapShotTime. That would indeed allow it to be changed. It’s hard to say for sure without any code though.

    If this is the problem, it’s typically that you’re referring to a captured variable which is declared outside the loop, but changed on every iteration of a loop. You can fix this by declaring a new variable which takes a copy of the original variable inside the loop, and only using that copy variable in the lambda expression. You’ll get a “new” variable inside the loop on each iteration, so you won’t have problems.

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

Sidebar

Related Questions

I am facing this strange problem with the following section of code <% if
I am facing this strange problem while working with Generic Base Classes. I am
I am facing a strange problem here. I have two projects, each of them
I'm facing this strange problem. I'm trying to read a file that is located
I am facing this strange problem with build path with Weblogic workshop. It's built
I am facing a strange problem while sorting a list of strings with integer
I am facing a strange problem with this UTF8String : parentMode = [NSString stringWithContentsOfFile:filePath
I'm facing a strange problem (which is connected to this problem ) regarding different
I'm facing this problem again and again, but can't find any solution (except mine,
I was facing this unique problem of generating a bit-mask based on the input

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.