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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:30:00+00:00 2026-06-09T00:30:00+00:00

when I click button1 should print A s but when I click button2 need

  • 0

when I click button1 should print A s but when I click button2 need to stop thread1 and need to start thread2, what is the wrong in here please help me

    private void button1_Click(object sender, EventArgs e)
    {
        if (thread2.IsAlive)
        {
            thread2.Suspend();
        }
        thread1 = new Thread(threadOne);
        thread1.Start();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        if (thread1.IsAlive)
        {
            thread1.Suspend();
        }
        thread2 = new Thread(threadTwo);
        thread2.Start();
    }

    private void threadOne() {
        for (int i=0; i < 20; i++ )
        {
            Console.Write("A");
            Thread.Sleep(500);
        }
    }

    private void threadTwo()
    {
        for (int i = 0; i < 20; i++)
        {
            Console.Write("B");
            Thread.Sleep(500);
        }
    }
  • 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-09T00:30:02+00:00Added an answer on June 9, 2026 at 12:30 am

    There’s quite a lot wrong, as the other posters have correctly pointed out. I would add this:

    1) Most threads in commercial-grade software never terminate during the lifetime of the application – they are written as infinite loops with blocking calls that wait for some sort of signaling from other threads or I/O operations.

    2) Continual create/terminate/destroy of thread objects is expensive, difficult to control, awkward-to-debug, unreliable and generally causes pain.

    3) If your multithread code contains any of the following:

    Suspend()
    Resume(), (except in some thread ctors)
    Join()
    Abort()
    IsAlive()
    

    You should probably think again 🙂

    I know you’re only learning, but sometimes it’s better to patch up holes before they get any bigger 🙂

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

Sidebar

Related Questions

I have an ASP.NET form (C#) but which I click this button that should
Here is what I want to happen: The user should click a link/button that
here is the code: http://jsfiddle.net/4WyPq/ So basically when I click 'button1' it animates then
So I wrote this code in java. It should print Mouse Click when I
When I select values from drop down then click on show button it should
When I click the button the text from the textbox should be written to
My Requiremet is when i Click on first button ,my panel should me me
On click on next button, the list should highlight/select next item in the listview.
Okay, let's start with this very simple button click method private void button1_Click(object sender,
I need to go to http://butlercountyclerk.org/bcc-11112005/ForeclosureSearch.aspx , enter data in the fields, then click

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.