Thanks Peter. This is awesome. I wasn't sure how to wait for next thread but
you made my life easy. Thanks a milliton for this. I just added one small
line to abort AD thread if file share already returned.
threadFileShare.Join();
if (dataFileShare != null)
{
data = dataFileShare;
if (threadAD.IsAlive)
{
threadAD.Abort();//Abort AD thread since we dont need
this data so why to spend resources on it
}
} }
Do you think its a good enhancmeent and will not cuse any trouble?
I did limited testing and it works fine.
Salim
> > [...]
> > I want to do these two opertions in parallel to reduce the time for
[quoted text clipped - 47 lines]
>
> Pete
Chris Mullins [MVP] - 20 Jun 2007 21:15 GMT
> I just added one small line to abort AD thread if file
> share already returned.
> threadAD.Abort();//Abort AD thread since we dont need
> this data so why to spend resources on it
Aborting the thread like that will cause all sorts of problems. These
problems may introduce major instability into your application.
You're better off just letting the thread finish and go away. Aborting it is
much worse than letting it suck up a few AD resources.

Signature
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
Peter Duniho - 20 Jun 2007 21:34 GMT
> [...]
> Do you think its a good enhancmeent and will not cuse any trouble?
> I did limited testing and it works fine.
As Chris says, aborting the thread is a very bad idea.
If you had complete control over all of the code executed within the
thread, then _maybe_ you could get away with aborting the thread, even
though doing so would still be poor design and likely to create
hard-to-track-down bugs.
But given that you are calling external code, you definitely should _not_
abort the thread. You have no way to ensure that the external code can
deal with this gracefully, and it's really not going to hurt anything to
allow the query to go on without you. You clearly can afford the
processing in the general case, and so you should easily be able to afford
it in all cases.
Pete