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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:32:21+00:00 2026-05-24T03:32:21+00:00

I have several thread synchronization questions involving a simple .NET C# design. I have

  • 0

I have several thread synchronization questions involving a simple .NET C# design. I have ideas on how to do the synchronization, but I would like to pass the ideas by other programmers that have more .Net experience than myself (almost anyone).

The design:

This is test control software.

There is a GUI in one thread (GUI thread) that has start, stop gracefully, abort, pause and resume buttons. In addition, it displays the results of each test. The results are updated as the test is run.

Then there is a thread that runs the test. It is kept separate from the GUI so the GUI will remain responsive. The test is simple with no real time considerations, things that blow up, etc.

Then there is a data class with the results of the tests.

I was thinking of making the data class a global static (so there will only be one) and shared between the two threads protected by means of a Mutex. The run class would get the Mutex, then update the data, release the Mutex and then call a delegate method that updates the GUI. Is there are better way of doing this?

The abort, stop gracefully, pause, and resume are more difficult. The run test method is chugging along in its own thread when suddenly the user wants to change things. The stop gracefully, pause and resume could be handled with flags in the data class that are checked by the run thread periodically. Those flags could be set by the GUI thread (using the Mutex again of course). And abort… How about killing the run thread and then calling a method that puts all the test equipment in a known state? Is there a better way of doing this?

  • 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-24T03:32:21+00:00Added an answer on May 24, 2026 at 3:32 am

    I agree that your question could be more specific, but I’ll take a shot.

    You’re generally correct about using Flags to signal your worker thread when it should pause/resume/stop gracefully (Auto and ManualResetEvent may also come in handy). You are also correct that Abort is going to be your biggest problem. Since you are presumably calling into code not your own (or at least, code that isn’t aware it’s being called on a worker thread), you have no way of signaling the worker thread that it should abort when it’s in the middle of a test. Using Thread.Abort is “considered harmful” and could certainly leave the process in a strange state. You could try using an AppDomain to sandbox the execution of the test code, which would allow you to simply teardown the entire AppDomain in the event of an abort. This would be a good approach anyway, since the code you’re testing could be modifying global state, thereby effecting future test runs in the same process.

    Also, since it sounds like you’re writing some kind of testing UI/framework, have you considered using an existing package like NUnit or the test capabilities built into Visual Studio?

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

Sidebar

Related Questions

I have several old 3.5in floppy disks that I would like to backup. My
I have several questions regarding Python threads. Is a Python thread a Python or
I have several lines of a method that I would like to ensure that
I have several thread pools and I want my application to handle a cancel
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
I have a problem handling messages in a Thread. My run-method looks like this
I have several threads that write to the same int. Each thread increment the
I have given a lot of thought before posting this questions. I have several
i've read several thread for this question but unfortunatly not found the answer to
I have several Silverlight, WP7 and ASP.NET MVC client applications Most allow anonymous access

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.