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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:00:01+00:00 2026-06-13T18:00:01+00:00

I have developed a socket program . I have the problem with the client

  • 0

I have developed a socket program . I have the problem with the client side socket program it gets data from multiple servers,one at a time and update the details in listview. It happens inside a infinite loop.

while(true) 
{

}

I want to exit this this loop in the middle period, I used button click event to do that

foreach (Process myProc in Process.GetProcesses())
{
    if (myProc.ProcessName == "procees name")
    {
        myProc.Kill();
    }
}

but it’s too slow, I want to pause that process and kill it. Help me to pause currently running process.

  • 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-13T18:00:03+00:00Added an answer on June 13, 2026 at 6:00 pm

    Since you mention the process is your own application, you can just exit the application yourself instead of killing the application. Your question turns out more to be “how can I exit my program”.

    Firstly, your button may not seem responsive since you’re running an infinite loop. One (bad) way of doing it is like this:

    private bool _exit = false; //member variable
    while(true && !_exit) 
    {
        Application.DoEvents();
    }
    

    Application.DoEvents is important to make your application keep listening to other actions. And then,

    private void btn_Click(object sender, EventArgs e)
    {
        _exit = true;
    }
    

    The ideal way imo is to transfer the job of getting data from servers to a background process. May be something like this:

    BackgroundWorker _backgroundWorker = new BackgroundWorker(); //member field
    
    void Listen()
    {
       _backgroundWorker.WorkerSupportsCancellation = true;
       _backgroundWorker.WorkerReportsProgress = true;
       _backgroundWorker.DoWork += (sender, e) => { while(condition)//bla bla; }
       _backgroundWorker.RunWorkerAsync();
    }
    

    And then upon your cancellation click,

    private void btn_Click(object sender, EventArgs e)
    {
        _backgroundWorker.CancelAsync();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a Java server using Eclipse that accepts TCP socket connection from
My problem statement is as follows :- I have developed Client-Server model based Application
I have a problem, I've developed a Client and Server wrapper for my personal
I have developed a java client server app based on socket programming. I am
I have developed a windows service which reads data from a database, the database
I have a web tool developed, which uses node.js and socket.io. it's a one
I have developed a Node.js application which receives data from TCP and at the
I have developed a small administration page for game servers which you can add/remove/edit
I have developed a Java socket server connection which is working fine. When started
I have a client socket which sends messages to the server.I want to get

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.