oc A

oc A

  • NA
  • 30
  • 0

Kill Threads

Mar 4 2008 5:03 AM

I am using VB.NET 2003 windows appln.... In this appplicatn i am creating many threads on a button click.... The code is

    Private Sub Initstart()
        Label5.ForeColor = System.Drawing.Color.Green
        Label5.Text = "Service Running"
        If Listening = False Then
            Dim T As New Thread(AddressOf Listen)
            T.IsBackground = True
            T.Start()
        Else
            Listening = False
        End If
    End Sub

    Private Sub Listen()
        Listening = True
        Listener.Start()
        Do Until Listening = False
            sb.Socket = Listener.AcceptSocket()
            sb.Socket.BeginReceive(sb.Buffer, 0, sb.Buffer.Length,      SocketFlags.None, AddressOf ReceiveCallBack, sb)
        Loop
    End Sub

    Private Sub ReceiveCallBack(ByVal ar As IAsyncResult)
    End Sub


In another Button click i want to kill all these threads and again go to Listening mod e... How i can do the coding for this
Anybody plz help


Answers (1)