|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to kill a threadi read a list of machines and use ThreadPool.QueueUserWorkItem to thread each machine using a timer. If the machine is not pingable, i wish to kill the thread that checks the ping function, so that the next poll will not run again. Any advice ? *********************************************************************** Private Sub OnTimerElapsed(ByVal sender As Object, ByVal e As System.timers.ElapsedEventArgs) For Each computer In Me.machines m_utl = New utility(m_kbhotfix, m_domain, m_ntid, m_pwd) ThreadPool.QueueUserWorkItem(AddressOf m_utl.pollmachines, computer) Next end sub public class utility Public Sub pollmachines(ByVal state As Object) computer = CType(state, String) If Not pingmachine(computer) Then 'how to kill the thread that does the last pollmachines End If end sub public function pingmachine as boolean pingmachine =false end function end class as far as i know. "ThreadPool.QueueUserWorkItem" is used to as system
to run thread onbehalf of you. and it executes while your appDomain is alive. another thing is the callback function you assigned to "ThreadPool.QueueUserWorkItem" doesnt takes function with reference parameter so that it is not possible to get value back into passed parameter. other thing is that, "ThreadPool.QueueUserWorkItem" return boolean value which tells whether your method is queued successfully or not so here also you dont get chance to return value from your method. in short you have to menually check for the pings and avoid such computers instead of depending on "ThreadPool.QueueUserWorkItem" coz it has no capability to answer whether your method successfully ckecked for the ping or not. so u have to look for another way.
VB for .NET Recommended?
They do this in C# can't we do it in VB?? C DLL Callback to VB.NET 2005 how to prevent multiple instances of 2nd form? aggregation simple .net code column subtotals in a datagrid Checking a string for filename compliance reuse query results for multiple object populations? (and dynamic variable names?) Wordwrap in VB.Net listbox? Crystal Report parameter dialog box |
|||||||||||||||||||||||