Multithreading Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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.
 
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.
 
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?
 
Back
Top