Can resource of system be disposed when a thread is aborted?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fjlpf

    Can resource of system be disposed when a thread is aborted?


    I create a new thread, and in it, create a socket.

    Now I want to terminate the thread in main thread, but

    can the socket be disposed automaticly?

    If it can't, how can I manage this situation?

    Thanks in advance!
  • Miha Markic

    #2
    Re: Can resource of system be disposed when a thread is aborted?

    Hi,

    Yes, it can.
    Add a try/catch handler to your thread, i.e:

    Init socket
    try
    {
    ...
    }
    catch (ThreadAbortExc eption ex)
    {
    // dispose here
    }

    --
    Miha Markic - RightHand .NET consulting & software development
    miha at rthand com

    "fjlpf" <anonymous@disc ussions.microso ft.com> wrote in message
    news:3d1001c3aa 94$04db52b0$a60 1280a@phx.gbl.. .[color=blue]
    >
    > I create a new thread, and in it, create a socket.
    >
    > Now I want to terminate the thread in main thread, but
    >
    > can the socket be disposed automaticly?
    >
    > If it can't, how can I manage this situation?
    >
    > Thanks in advance![/color]


    Comment

    • fjlpf

      #3
      Re: Can resource of system be disposed when a thread is aborted?


      Thank you very much

      Comment

      Working...