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 90967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:57:22+00:00 2026-05-10T22:57:22+00:00

We have an application that generates simulated data for one of our services for

  • 0

We have an application that generates simulated data for one of our services for testing purposes. Each data item has a unique Guid. However, when we ran a test after some minor code changes to the simulator all of the objects generated by it had the same Guid.

There was a single data object created, then a for loop where the properties of the object were modified, including a new unique Guid, and it was sent to the service via remoting (serializable, not marshal-by-ref, if that’s what you’re thinking), loop and do it again, etc.

If we put a small Thread.Sleep( …) inside of the loop, it generated unique id’s. I think that is a red-herring though. I created a test app that just created one guid after another and didn’t get a single duplicate.

My theory is that the IL was optimized in a way that caused this behavior. But enough about my theories. What do YOU think? I’m open to suggestions and ways to test it.

UPDATE: There seems to be a lot of confusion about my question, so let me clarify. I DON’T think that NewGuid() is broken. Clearly it works. Its FINE! There is a bug somewhere though, that causes NewGuid() to either: 1) be called only once in my loop 2) be called everytime in my loop but assigned only once 3) something else I haven’t thought of

This bug can be in my code (MOST likely) or in optimization somewhere.

So to reiterate my question, how should I debug this scenario?

(and thank you for the great discussion, this is really helping me clarify the problem in my mind)

UPDATE # 2: I’d love to post an example that shows the problem, but that’s part of my problem. I can’t duplicate it outside of the whole suite of applications (client and servers).

Here’s a relevant snippet though:

OrderTicket ticket = new OrderTicket(... );  for( int i = 0; i < _numOrders; i++ ) {     ticket.CacheId = Guid.NewGuid();     Submit( ticket );  // note that this simply makes a remoting call } 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:57:23+00:00Added an answer on May 10, 2026 at 10:57 pm

    Does Submit do an async call, or does the ticket object go into another thread at any stage.

    In the code example you are reusing the same object. What if Submit sends the ticket in a background thread after a short delay (and does not take a copy). When you change the CacheId you are actually updating all the pending submits. This also explains why a Thread.Sleep fixes the problem. Try this:

    for( int i = 0; i < _numOrders; i++ ) {     OrderTicket ticket = new OrderTicket(... );     ticket.CacheId = Guid.NewGuid();     Submit( ticket );  // note that this simply makes a remoting call } 

    If for some reason this is not possible, try this and see if they are still the same:

    ticket.CacheId = new Guid('00000000-0000-0000-0000-' +       string.Format('{0:000000000000}', i)); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that generates around 10000 printed pages per month. Each report
I have one an application that generates .pcl files. Once generated they are saved
I have an application that generates div boxes dynamically. The boxes are overlapping each
I have an application that generates barcode in image format and it is read
I have a application that generates a couple of different mails. These mails are
I have an application that generates xml files, and they might contain special characters.
I have a Winforms application that generates its own PrintDocument object for printing. It
I have a simple c++ application that generates reports on the back end of
I have an application that takes some input and generates configuration files as output.
Background: I have an application that, when installed, generates a random identifier (AppId). When

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.