MultiThreading an ActiveX DLL call...

W

Willy Denoyette [MVP]

Cybertof said:
Thanks for the hint about the Marshal.ReleaseComObject(...).

What made me think it does not run on the background thread is :
If I put the GC.Collect() on the big array, it slows down the main UI.
If I remove the GC.Collect(), the main UI is not affected.

Does it sound correct to you ?

GC.Collect() is a static method, not instancied within a thread, so
where does it execute ? It 'touches' all orphelin memory parts, from all
threads within the main process ?


Cybertof.

GC.Collect() forces a full collect, that is all generations are scanned for
non rooted objects during a sweep.
The GC.Collect() obviously runs on the thread that initiated the call (it
calls into the CLR), once started the CLR suspends all managed threads and
prevent all unmanaged threads to return or call into managed code.
Now in your particular case, it might take some time to collect and as such
it might have a visible impact on the UI. Simply put the data you are
handling is too large.


Willy.
 

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

Top