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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:02:31+00:00 2026-06-08T02:02:31+00:00

I have a log-on process from an API I don’t own that occasionally hangs.

  • 0

I have a log-on process from an API I don’t own that occasionally hangs. If it takes longer than, say, 30 seconds, I would like to kill it and retry (as it should take only about 2-3).

I’m a little confused about how aborting threads works, and whether or not I need to join after abortion. Here’s my questions followed by an example of what I’m trying to do:

Questions:

  1. Abort throws a thread abortion exception in the thread its called on. Does that propagate? Do I need to explicitly handle in the calling thread it or does the thread just die?

  2. Do I need to join an aborted thread so it doesn’t zombify, or am I just confused from the *NIX world of programming?

    public static Session GetSession()
    {
        Session session = new Session("user", "pass");
    
        try
        {
            //Create a thread to get the session so we can kill it if it hangs.
            Thread thread = new Thread(() => session.Logon());
    
            //Create a thread to kill the session thread if it hangs.
            Thread watcher = new Thread(() => HangKill(thread));
    
            //Start both threads.
            thread.Start();
            watcher.Start();
    
            //Wait for session thread to finish - abort kill thread if it does.
            thread.Join();
            watcher.Abort();
            watcher.Join();
        }
        catch (Exception ex)
        {            
            status = ex.ToString();
        }
    
        return session;
    }
    
    
    public static void HangKill(Thread t)
    {
        Thread.Sleep(30);
    
        if (t.IsAlive == true)
        {
            t.Abort();
        }
    }
    
  • 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-08T02:02:32+00:00Added an answer on June 8, 2026 at 2:02 am

    Aborting threads in your own process is dangerous. (As well as in other processes, though.) The thread may own some locks, may be in the process of updating critical structures etc etc. So this is not the way to go.

    I would suggest including the service in question into another process, so you can kill that process if something is going wrong. Use IPC (shared memory? WCF?) for communication with that process.

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

Sidebar

Related Questions

I have a python process running now , but it hangs with no log、no
So i have this crash log from my application. I don't have much experience
I cannot log messages from my delayed_job process. Here is the job that is
I have a background process read from named pipe. for example mkfifo /tmp/log.pipe ./myprog.sh
I have an log file that I need to extract specific patterns from. I
I have an API where I need to log which ids from a table
If i have file for eg: a log file created by any background process
We've faced strange problem. We have log on service, that authenticates user, adds auth
I have a log method which saves to a file that is named the
I have a log file that I'm trying to append data to the end

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.