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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:16:45+00:00 2026-06-13T22:16:45+00:00

I have a project in C#/Windows Forms, where I have a simple form with

  • 0

I have a project in C#/Windows Forms, where I have a simple form with a PictureBox that i draw images to from a background thread. If I close the form while drawing is active the background thread crashes when trying to perform invoke to update the bitmap, which is quite logical. I tried putting an AutoResetEvent that the destructor would wait on, so that destructor would not return until all drawing is done and the background thread knows it is supposed to exit. But I concluded that the crash happens before destructor is executed so I started to wonder, at what point are the components of the form destroyed? I assume that before the destructor? So what is a safe place to wait for the drawing to finish? Override Dispose() and do it there?

  • 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-13T22:16:46+00:00Added an answer on June 13, 2026 at 10:16 pm

    That is what I would think, there is already a Dispose(bool disposing) method in the Designer file e.g. MainForm.Designer.cs.

    I would put some code to close/finish the background thread in the beginning of that method. And a AutoResetEvent or a ManualResetEvent would be a good way to do it.

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

Sidebar

Related Questions

I have a Windows Forms project in Visual Studio that reads configuration files from
In my windows forms project I have a parent form that is creates other
I have a very simple windows form project with Entity Framework. Simply I draged
I'm trying to make a simple form that contains textboxes that draw from a
I have a Windows Form Application Project that references a class library containing user
I have a C# project using windows forms. I need to let the user
I have a Windows Forms project in Visual Studio 2008, which references a library
I have a C# Windows Forms project open with some C# code in it.
I have a c# windows form project using watin. I would love to attach
Hey all, i have made a simple form that mimiks the jQuery GROWL effect

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.