Solved

VB.NET Question about killing threads completely, I'm stumped.

Posted on 2007-03-22
3
1,002 Views
Last Modified: 2012-05-05
I have a thread now that establishes an internet connection and begins to handle packets, etc.

I've run the t.abort() call on the thread and set t = nothing and it appears as if the object is gone (if I call t.abort() again it gives me an object error that its not defined)

the strange thing is the connection is not terminated (i can see packets still being processed)... so I'm a bit confused

Can someone clarify to me the BEST way to totally kill a thread and everything related to it immediately?

I'm guessing that terminating the thread only kills the sub process that was called at the addressof... any way to go deeper than that?
0
Comment
Question by:mcainc
3 Comments
 
LVL 4

Accepted Solution

by:
meenasree earned 500 total points
ID: 18777949
after abort
invoke Thread.Sleep(time) for some time and see whether yr problem gets solved
0
 
LVL 11

Expert Comment

by:Babycorn-Starfish
ID: 18804885
Hi,

what are you using for the connection? If it's something like a socket wrap it in a try..catch block and just set it to null, close it  or something. The process should then drop into the catch and then exit the thread.
0
 
LVL 5

Expert Comment

by:andr_gin
ID: 23096933
If Thread.Abort ist called on unmanaged Code (for example a blocking read on a network stream) the thread is aborted after it enters the managed code again. Thread.sleep is not a solution because the time is not really known. If you you have a TCP Listener without a timeout this could be forever if noone connects. If you have a blocking read from a network stream without a timeout and the protocoll got stuck and the other side does not send anymore this also can take a long time.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now