Threading and Scope

  • Thread starter Thread starter tomb
  • Start date Start date
T

tomb

Hi all.
I can't find anything to explain how to prevent losing my object reference.

I have a function that instantiates a document object, passes it to
another class, then uses a thread for the other class to process data
and populate the document with a report, then open the document. It all
works great except the document opens and immediately closes.

What I don't understand is this:
If I Dim as New the document object in a function, then process the data
and report in the other class without threading, the document opens and
stays open even though the function is exited and the document object
and other class go out of scope.
But, if I do the same thing using threading, the document and class
still go out of scope, but now I lose the document completely.

Can anyone explain this? Better yet, how to avoid this? Or point me to
a reference?

So frustrating, so frustrating...

Thanks,
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top