I have a program I use to extract distribution list information into a CSV file for another program to digest. When I run the primary loop as a call in response to a button click it works fine. However, I need to run the loop as a thread. When I change the program structure to support this I get an error "object does not match target type" when I try to access the domain's list of DLs.

foreach (DistributionList dl in lists) {......

I've tried bringing in a new reference to the DL list to the method but it makes no difference.

Do I need to create a new connection to the domain within the method and then local System, domain and list references?

This is using C#, GW 8.0.2. Any thoughts?