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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:59:24+00:00 2026-05-12T21:59:24+00:00

I’ve recently set some coursework for some undergraduate students for which they have to

  • 0

I’ve recently set some coursework for some undergraduate students for which they have to use a small and relatively simple C# library provided to them. The main purpose of this library is to display a simple form which is composed of a coloured grid (which they can manipulate), a number of buttons and a label with some text.

The class they extend provides a number of abstract methods which they must implement, one of which is called UpdateAction and is automatically invoked at set intervals.

I have not encountered the following problem myself but in labs some of the students have encountered an intermittent InvalidOperationException being thrown from within their UpdateAction method when they close their form. The error message is the error I would normally expect to see when you try and modify the UI from a different thread but there are just a double quote '' where you’d normally see the name of the offending control.
If this continues to be an issue we will need to reissue a fixed version of the library to them though we have already stated that this error will not impact marking of their work in any way (since it appears to be a flaw in our code).

As far as I can tell the students must be closing the form at such a point that the update is running and the controls they are modifying get disposed of before the update thread gets stopped i.e. it appears the controls have become null. The strange thing is how intermittent it is, some students have never had the issue while others have had it continually. I have never personally encountered it throughout my development of the model solutions for the coursework or in developing the library itself.

So my question is at what point in a forms life cycle do the controls on it get disposed of and therefore where would it be best to put the code that stops the update thread? Currently this code is in the forms Dispose method, would it be better placed elsewhere?

  • 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-12T21:59:24+00:00Added an answer on May 12, 2026 at 9:59 pm

    How are you stopping the thread? Are you sure it is stopping before you close the window? You should ensure you stop it by setting a flag in the thread loop. You then have to wait for the thread to exit.

    Thread

    while (running)
    {
        // thread stuff
    }
    

    Form

    thread.running = false; // or use your own Stop() method that does the same thing
    thread.Join();
    

    If you want a responsive system you need to ensure the thread is able to exit within a short time of obtaining the stop signal.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.