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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:16:54+00:00 2026-06-02T12:16:54+00:00

Thread.Suspend() method is obsolete as you know. I want to suspend thread immidiately when

  • 0

Thread.Suspend() method is obsolete as you know. I want to suspend thread immidiately when button click event comes. I used Thread.Suspend() and it works perfect but everyone suggest that using Thread.Suspend() method is not a good method to suspend the task. I used a flag to suspend the task but every time when a button click event comes, i have to wait to exit from task. I used Thread.IsAlive flag to wait the thread to exit but this method freezes form.

void ButtonClickEvent(object sender, ButtonClickEventArgs e)
{
    TheadExitFlag = false;

    if(MyThread != null)
    {
        while(MyThread.IsAlive);
        //MyThread.Suspend();
    }
}

void MyTask(void)
{
    while(TheadExitFlag)
    {
        // some process
        Thread.Sleep(5000);
    }
}

How can i suspend the thread immidiately?

  • 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-02T12:16:56+00:00Added an answer on June 2, 2026 at 12:16 pm

    There is no alternative with the same functionality, AFAIK. I am not sure if the problems with an OS Suspend() could be worked around within the language/libraries, but no attempt has been made to do so, so maybe it’s too difficult or even sensibly impossible.

    Until such an alernative exists, you are reduced to polling for a suspend flag and then waiting on some synchronization object for a ‘resume’ signal. I have used AutoResetEvent for this.

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

Sidebar

Related Questions

In Win32 I want to suspend a thread using Suspend(GetCurrentThread()); but I find I
I can suspend the thread with user input in console,but can't resume it again
I have a thread doing things in background and I want to suspend it
How to suspend current thread for 20 seconds in java?
thread.join() will call thread.wait() , but who and when notifies (either with thread.notify() or
I need to design a thread-safe logger. My logger must have a Log() method
I can suspend a thread of another process by using SuspendThread(). Is there any
In my previous question how to suspend a thread for 1 ms? it was
I implemented multithreading through implemnting runnable and overriding run() . I want to suspend
I have a thread that running into an activity. I don't want that the

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.