Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on 

Windows Service clean up threads on stop

WHat would be the way to properly clean up these threads in the Windows Service OnStop?

Dim phoneWorkerThread As New Threading.Thread(AddressOf startPhoneMonitoring)
phoneWorkerThread.Name = "Thread " + " | [" + dataRowString + "] " + System.Guid.NewGuid.ToString()
phoneWorkerThread.IsBackground = True
phoneWorkerThread.Start(sendRow)

Open in new window

Visual Basic.NET.NET ProgrammingMicrosoft Development

Avatar of undefined
Last Comment
Larry Brister
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

If I remember correctly, you maintain a list of these threads right? You would need to abort all these threads before the service dies.
Avatar of Larry Brister
Larry Brister
Flag of United States of America image

ASKER

CodeCruiser,
  So along these lines (using the dictionaty list)

            Dim t As Thread
            For Each t In Diagnostics.Process.GetCurrentProcess().Threads
                t.Abort()
            Next t
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Larry Brister
Larry Brister
Flag of United States of America image

ASKER

Bingo!  Thanks
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo