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

  • Home
  • SEARCH
  • 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 42093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:17:02+00:00 2026-05-10T15:17:02+00:00

I need to have a thread signal another if the user wishes to interrupt

  • 0

I need to have a thread signal another if the user wishes to interrupt execution, however I’m unsure about how to implement the signaling/signal-checking mechanism. I wouldn’t like to have a singleton in my project (like a global bool), but is there an alternative?

In this thread people suggest proper structures for that in C++, but I don’t know about anything similar in .NET. Could somebody please shed some light?

  • 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. 2026-05-10T15:17:03+00:00Added an answer on May 10, 2026 at 3:17 pm

    Try out BackgroundWorker. It supports progress updates and cancellation of a running task.

    If you want one thread to wait until another thread has finished doing its thing, then Monitor.Wait and Monitor.Pulse are good, as is ManualResetEvent. However, these are not really of any use for cancelling a running task.

    If you want to write your own cancellation code, you could just have a field somewhere which both threads have access to. Mark it volatile, e.g.:

    private volatile bool cancelling; 

    Have the main thread set it to true, and have the worker thread check it periodically and set it to false when it has finished.

    This is not really comparable to having a ‘global variable’, as you can still limit the scope of the semaphore variable to be private to a class.

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Why not perform the check right before they submit the… May 11, 2026 at 11:20 am
  • added an answer Or something like this : Inherit from your notifier and… May 11, 2026 at 11:20 am
  • added an answer According to the 2.0 documentation here there is a python… May 11, 2026 at 11:20 am

Related Questions

I need to have a thread signal another if the user wishes to interrupt
I have a Queue object that I need to ensure is thread-safe. Would it
I am new to threads and in need of help. I have a data
I need to have a summary field in each page of the report and
I need to have a script read the files coming in and check information
I need to have a working web browser in a fullscreen Direct3D application. For
I need to have a string, based on an integer, which should always have
I need to have a routine/function/stored proc/whatever to archive particular accounts from our 'active'
I need to have a single instance application (as per this answer ), but
I need to have a process that compiles daily data into an PDF that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.