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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:44:02+00:00 2026-05-31T13:44:02+00:00

I have an issue with threading in my application. As often with threading issue,

  • 0

I have an issue with threading in my application.

As often with threading issue, it doesnt occur all the time.
Sometimes a collectionChanged exception occurs on this code :

    SyncLock _padLock
        System.Threading.Monitor.Enter(serie)
        For Each dat In serie.Lignes
            WriteLine(dat.Columns(), False, 0, False)'exception here
        Next
        System.Threading.Monitor.Exit(serie)
    End SyncLock

Basically a serie contains lines, which are arrays of objects.

Why is another thread able to modify the series, if I have a monitor lock on that object ?

Also, I dont seem to be able to see when sections are locked in VS. Is there a specific way of doing so ?

Edit :

I modified the code so that the lock is done properly. That bug is gone. But now im trying to find out another bug im having.
This one is really tricky, because sometimes I get an unexpected result (highly due to a race) but I can never reproduce it while I have breakpoints in my code.

This is a really hairy situation.

  • 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-05-31T13:44:04+00:00Added an answer on May 31, 2026 at 1:44 pm

    Can you use .Net 4.0?
    ConcurrentBag would be a better type to support your collection, so that is threadsafe.
    You are currently locking twice (_padLock and serie), but this does not protect you against anyone modifying the collection without locking.
    The other alternative could be to create a local copy of the collection and loop around this copy, but this does not eliminate the race.

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

Sidebar

Related Questions

I have an issue with System.Threading.Timer. I am scheduling some actions using a time
I'm not sure if I have a threading issue here or not. On the
I believe I have a potential threading issue. I have a user control that
I have a C# application that simply parses all of the txt documents within
I have a client server application with multi-threading. The server side is failing with
I have an issue using c# on .Net 4 in a MVC web application,
I have a MFC document/view C++ graphics application that does all its drawing to
I have used threading in my web application which I have mentioned below: var
Im having an issue with my progress bar. Now I have looked through all
Hi All, I have an application (windows service/C#) which starts EXCEL and POWERPOINT and

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.