Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Do I have to close all the opened sockets when I close the app,

or the sockets are being closed automaticly when the app is closed?

Posted

The problem i have faced is similar to like this

 

I have a TCP Listner, and i am assigining a new thread to a new incoming connection, if there are some active connections then although application is closed its proces in back is still running and then i have to go to taskmanager and then kill the process

The one and only

Dr. Madz

eee-m@il

Posted

In any case, if I have a thread and in this thread I have

int ret = soc.Receive(receive, receive.Length, 0); 

 

I will have to use the 'Suspend' method before aborting the thread. No?

Posted

suspending the task before closing it, resolved me a problem.

 

When I used to close a thread which has the command

int ret = soc.Receive(receive, receive.Length, 0);

gave the following Exception:

 

 

System.Threading.ThreadAbortException: Thread was being aborted.

at System.ComponentModel.Win32Exception..ctor(Int32 error)

at System.Net.Sockets.SocketException..ctor()

at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)

at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 size, SocketFlags socketFlags)

at MaleClient.FrmMain.RecieveData() in c:\documents and settings\erany\my documents\visual studio projects\matchmaker\maleclient\frmmain.cs:line 221

  • *Gurus*
Posted
That is how threads work-- the only way to terminate them is to throw an exception, catch it at the application level and ignore it. Calling Thread.Suspend() is essentially doing nothing, since a subsequent call to Thread.Abort() will implicitly resume the thread and then abort it.
  • *Gurus*
Posted

No, they won't.

 

Dim t As New Thread(AddressOf ThreadProc)
t.Start()
Thread.Sleep(2000)
t.Abort()

 

Private Sub ThreadProc()
Try
	Do
		Trace.WriteLine("Executing...")
	Loop
Catch e As ThreadAbortException
	MessageBox.Show("""Thread.Abort()"" has been called.", "")
End Try
End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...