Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Thread NOT aborting nicely!!!!

Thread NOT aborting nicely!!!!

Scheduled Pinned Locked Moved C#
helpsysadmintutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WetRivrRat
    wrote on last edited by
    #1

    Hey, running an app that has to enumerate thru a treeView and create a connection to each node(or pc). because our network is so large i need to give the users the ablity to close the connection/exit the application prior to the connection closing itself. The problem i'm running into is that i'm running the treeView enumeration on a separate thread (due to the time/system expense and it was continually locking up the interface) and I can't elegantly kill the thread. I intermittently receive "Thread was being aborted" when trying to stop/abort the thread. I've searched around and all i can find is related to web redirects, which isn't my problem. I've attempted to follow the msdn directives regarding this but haven't had any luck(thread.join). I've also tried to look into closing the connection as that would allow the thread to close properly, but i can't find anything on how to close a managementScope object. (I may have not looked hard enought on this part :~ ) I could use any help that you may offer. string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

    L 1 Reply Last reply
    0
    • W WetRivrRat

      Hey, running an app that has to enumerate thru a treeView and create a connection to each node(or pc). because our network is so large i need to give the users the ablity to close the connection/exit the application prior to the connection closing itself. The problem i'm running into is that i'm running the treeView enumeration on a separate thread (due to the time/system expense and it was continually locking up the interface) and I can't elegantly kill the thread. I intermittently receive "Thread was being aborted" when trying to stop/abort the thread. I've searched around and all i can find is related to web redirects, which isn't my problem. I've attempted to follow the msdn directives regarding this but haven't had any luck(thread.join). I've also tried to look into closing the connection as that would allow the thread to close properly, but i can't find anything on how to close a managementScope object. (I may have not looked hard enought on this part :~ ) I could use any help that you may offer. string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      wetrivrrat wrote:

      The problem i'm running into is that i'm running the treeView enumeration on a separate thread (due to the time/system expense and it was continually locking up the interface) and I can't elegantly kill the thread. I intermittently receive "Thread was being aborted" when trying to stop/abort the thread.

      As long as your applcation is not left in an unusable state, IMO just catching that should be ok. Another idea is to use a bool (perhaps static) value somewhere that u can set to exit the thread. You can also look at some other classes in the Threading namespace, but normally a simple check is enough. :)

      xacc.ide-0.1.2 'Milestone' - includes full source
      Now supporting 24 languages including F#, FreePascal/Delphi and VB.NET

      W 1 Reply Last reply
      0
      • L leppie

        wetrivrrat wrote:

        The problem i'm running into is that i'm running the treeView enumeration on a separate thread (due to the time/system expense and it was continually locking up the interface) and I can't elegantly kill the thread. I intermittently receive "Thread was being aborted" when trying to stop/abort the thread.

        As long as your applcation is not left in an unusable state, IMO just catching that should be ok. Another idea is to use a bool (perhaps static) value somewhere that u can set to exit the thread. You can also look at some other classes in the Threading namespace, but normally a simple check is enough. :)

        xacc.ide-0.1.2 'Milestone' - includes full source
        Now supporting 24 languages including F#, FreePascal/Delphi and VB.NET

        W Offline
        W Offline
        WetRivrRat
        wrote on last edited by
        #3

        Thanks for the response, i've included a small section of the code that deals with the thread abort calls. I guess a bit more description into what i'm receiving may help... its not so much the initial error, as i could find a creative way to handle it, but its that i'm receiving the error multiple times. So even if i catch the error i'll still have to deal with multiple instances of the same issue. After watching the system processes I can see that instead of increasing by only one thread, or maybe even two for that matter i'm actually increasing by 4 sometimes 7 while the app is enumerating thru the connection nodes... this is only a concern because i'm receiving sometimes 3 or more "Thread was being aborted" messages, so i wanted to see why. I've also tried to capture that message by using a try,catch, but haven't yet found a way to do it. not sure if that has anything to do with the unhandled exception nature of this message or not, but its just odd.... anyhow i'm sure i'm only confusing the situation more by explaining...

        case 3:
        result = MessageBox.Show("~","Please Verify", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
        try
        {
        if(result == DialogResult.Yes)
        {
        menuItem42.Visible=true;
        menuItem45.Visible=false;
        if (PcTree.IsAlive == true)
        {
        PcTree.Abort();
        PcTree.Join();
        label1.ResetText();
        progressBar1.Value = progressBar1.Minimum;
        }
        }
        }
        catch (ThreadAbortException abort)
        {MessageBox.Show(abort.Message + abort.StackTrace);}
        break;

        string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

        W 1 Reply Last reply
        0
        • W WetRivrRat

          Thanks for the response, i've included a small section of the code that deals with the thread abort calls. I guess a bit more description into what i'm receiving may help... its not so much the initial error, as i could find a creative way to handle it, but its that i'm receiving the error multiple times. So even if i catch the error i'll still have to deal with multiple instances of the same issue. After watching the system processes I can see that instead of increasing by only one thread, or maybe even two for that matter i'm actually increasing by 4 sometimes 7 while the app is enumerating thru the connection nodes... this is only a concern because i'm receiving sometimes 3 or more "Thread was being aborted" messages, so i wanted to see why. I've also tried to capture that message by using a try,catch, but haven't yet found a way to do it. not sure if that has anything to do with the unhandled exception nature of this message or not, but its just odd.... anyhow i'm sure i'm only confusing the situation more by explaining...

          case 3:
          result = MessageBox.Show("~","Please Verify", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
          try
          {
          if(result == DialogResult.Yes)
          {
          menuItem42.Visible=true;
          menuItem45.Visible=false;
          if (PcTree.IsAlive == true)
          {
          PcTree.Abort();
          PcTree.Join();
          label1.ResetText();
          progressBar1.Value = progressBar1.Minimum;
          }
          }
          }
          catch (ThreadAbortException abort)
          {MessageBox.Show(abort.Message + abort.StackTrace);}
          break;

          string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

          W Offline
          W Offline
          WetRivrRat
          wrote on last edited by
          #4

          okay, okay, it looks like i'm getting closer to the resolution.... it appears that either by accident( :confused: ) or by the objects design, i am actually creating at least 2 other threads at the same instance when i am starting the enumeration loop, so when i go to close it, the first actually closes nicely, its the others that are left in the loop that start #itching .... So, i'm off to see the wizard, the wonderful wizard of Threads to see what I have to do get home. Now, if i could only find my way.... :~ string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups