|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Multithreading ProblemI am trying to create a multithreaded VB 2005 application which attempts to create a new thread per Domain Controller (DC) in my environment. Each thread connects to its allocated DC and enumerates all computer objects and extracts the 'LastLogon' property. The results from each thread is then consolidated so that I can get the true lastlogon date for each computer object. However in my routine thats get actioned per thread, I have used the following line which seems to halt each thread and doesn't progress to the next line of code: Dim searcher As New DirectorySearcher("LDAP://" + dc.Domain.ToString & "/" & dc.Name) Where dc is defined as ActiveDirectory.DomainController. This is my method of connecting directly to a specific domain controller. Why would this process halt when it works fine if I do not use multithreading? Is there a better way of connecting directly to a domain controller that would get around this problem? Thanks, Michael. According to the DirectorySearcher class information in the help files:
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. HTH Dave Show quoteHide quote "Michael" <Mich***@discussions.microsoft.com> wrote in message news:9B4936F5-BEA0-48D4-B086-9415BB001735@microsoft.com... > Hi, > > I am trying to create a multithreaded VB 2005 application which attempts > to > create a new thread per Domain Controller (DC) in my environment. Each > thread > connects to its allocated DC and enumerates all computer objects and > extracts > the 'LastLogon' property. The results from each thread is then > consolidated > so that I can get the true lastlogon date for each computer object. > > However in my routine thats get actioned per thread, I have used the > following line which seems to halt each thread and doesn't progress to the > next line of code: > > > Dim searcher As New DirectorySearcher("LDAP://" + dc.Domain.ToString & "/" > & > dc.Name) > > Where dc is defined as ActiveDirectory.DomainController. > > This is my method of connecting directly to a specific domain controller. > Why would this process halt when it works fine if I do not use > multithreading? Is there a better way of connecting directly to a domain > controller that would get around this problem? > > Thanks, > Michael. > > Thanks David.
So I can only assume that the declaration that I am using, is using an instance member which is causing me thread problems. Is there any way around this because this leads me to believe that you cannot program with the DirectorySearcher object in a multithreaded application. Show quoteHide quote "David Lee Conley" wrote: > According to the DirectorySearcher class information in the help files: > > Any public static (Shared in Visual Basic) members of this type are thread > safe. Any instance members are not guaranteed to be thread safe. > > HTH > > Dave > > "Michael" <Mich***@discussions.microsoft.com> wrote in message > news:9B4936F5-BEA0-48D4-B086-9415BB001735@microsoft.com... > > Hi, > > > > I am trying to create a multithreaded VB 2005 application which attempts > > to > > create a new thread per Domain Controller (DC) in my environment. Each > > thread > > connects to its allocated DC and enumerates all computer objects and > > extracts > > the 'LastLogon' property. The results from each thread is then > > consolidated > > so that I can get the true lastlogon date for each computer object. > > > > However in my routine thats get actioned per thread, I have used the > > following line which seems to halt each thread and doesn't progress to the > > next line of code: > > > > > > Dim searcher As New DirectorySearcher("LDAP://" + dc.Domain.ToString & "/" > > & > > dc.Name) > > > > Where dc is defined as ActiveDirectory.DomainController. > > > > This is my method of connecting directly to a specific domain controller. > > Why would this process halt when it works fine if I do not use > > multithreading? Is there a better way of connecting directly to a domain > > controller that would get around this problem? > > > > Thanks, > > Michael. > > > > > > > On Sun, 30 Apr 2006 23:52:01 -0700, Michael
<Mich***@discussions.microsoft.com> wrote: Show quoteHide quote >Hi, Could this method call be failing whilst multithreading and generating> >I am trying to create a multithreaded VB 2005 application which attempts to >create a new thread per Domain Controller (DC) in my environment. Each thread >connects to its allocated DC and enumerates all computer objects and extracts >the 'LastLogon' property. The results from each thread is then consolidated >so that I can get the true lastlogon date for each computer object. > >However in my routine thats get actioned per thread, I have used the >following line which seems to halt each thread and doesn't progress to the >next line of code: > > >Dim searcher As New DirectorySearcher("LDAP://" + dc.Domain.ToString & "/" & >dc.Name) > >Where dc is defined as ActiveDirectory.DomainController. > >This is my method of connecting directly to a specific domain controller. >Why would this process halt when it works fine if I do not use >multithreading? Is there a better way of connecting directly to a domain >controller that would get around this problem? > >Thanks, >Michael. > an exception? As once moved to another thread this can cause the thread to silently die. This is my first real venture into multithreading. I have tried placing
Try...Catch blocks around the 'DirectorySearcher' declaration and also placed debug.print statements either side. No exceptions are being reported and the post debug.print statement also doesn't get executed. If each thread is dieing is there a way to report this back to the main application thread? Show quoteHide quote "Chris Chilvers" wrote: > On Sun, 30 Apr 2006 23:52:01 -0700, Michael > <Mich***@discussions.microsoft.com> wrote: > > >Hi, > > > >I am trying to create a multithreaded VB 2005 application which attempts to > >create a new thread per Domain Controller (DC) in my environment. Each thread > >connects to its allocated DC and enumerates all computer objects and extracts > >the 'LastLogon' property. The results from each thread is then consolidated > >so that I can get the true lastlogon date for each computer object. > > > >However in my routine thats get actioned per thread, I have used the > >following line which seems to halt each thread and doesn't progress to the > >next line of code: > > > > > >Dim searcher As New DirectorySearcher("LDAP://" + dc.Domain.ToString & "/" & > >dc.Name) > > > >Where dc is defined as ActiveDirectory.DomainController. > > > >This is my method of connecting directly to a specific domain controller. > >Why would this process halt when it works fine if I do not use > >multithreading? Is there a better way of connecting directly to a domain > >controller that would get around this problem? > > > >Thanks, > >Michael. > > > > Could this method call be failing whilst multithreading and generating > an exception? As once moved to another thread this can cause the thread > to silently die. >
VB2005 Pro Edition--Data Sources window is disabled when viewing forms
Adding a Web Reference changes DataTypes ??? Traversing a Collection Accessing one dimension of a multidimensional array Regular Expression Desperately needing direction with EncoderParameters and saving images under different compression/q Maximum Form Height? problem opening Excel file with Shell Displaying copied file names in textbox My.Computer.Network.IsAvailable question |
|||||||||||||||||||||||