Re: Thread apartment IE7



"Cedric Scheyder" <cedric.scheyder@xxxxxxxxxxxxxxxxx> wrote in message
news:A1C1119C-AEEE-4DF8-B966-878BCF2F22E6@xxxxxxxxxxxxx
I'm trying to create a worker thread to deal with network I/O in a
BHO.
I have a class that save the IUknown object to a pointer.
It creates then the worker thread.
I have a function that list a frames in a IHTMLDocument2 object that
works fine when called from the main thread, but it crashes on
myDoc->get_frames(&pFrameColls) when called from the worker thread.
Even if i marshall it or not.
In debug mode, all pointers seem exactly the sames in worker or main
thread.

Show the code where you marshal the pointers. After marshalling you
should definitely get a pointer different from the original raw pointer.
You are doing something wrong.

Do you initialize COM on the worker thread?

Note that it's largely pointless to manipulate DOM from a worker thread.
You already know that all MSHTML interface pointers need to be
marshalled to the worker. Every method call through such a marshalled
pointer is transferred to the main thread, executed there, and any
results marshalled back to the worker. At the end of the day, the
"worker" doesn't really do any work, it spends most of its time waiting
on the main thread to do it instead.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: 0xFEEEFEEE
    ... unless you delete all of the uses of the pointer before deleting the pointer there will always be a window of opportunity for it to get used when you didn't intend it to. ... This sounds like a good plan if the tree is not accessible. ... The object that I create is basically a struct and holds some numerical information and a pointer to another object - a 'Worker' object. ... When I retreive my tree's pointer to the deleted Worker, it is not a NULL pointer, but points to what appears to be a valid object (memory location looks normal). ...
    (microsoft.public.vc.mfc)
  • Re: 0xFEEEFEEE
    ... tree control. ... and a pointer to another object - a 'Worker' object. ... the Worker object is deleted from the system. ... what appears to be a valid object (memory location looks normal). ...
    (microsoft.public.vc.mfc)
  • Re: 0xFEEEFEEE
    ... which stores a pointer to another "worker" ... object (call it Worker). ... what appears to be a valid object (memory location looks normal). ... I understand why I am seeing this crash - I am using an area of memory ...
    (microsoft.public.vc.mfc)
  • Re: 0xFEEEFEEE
    ... Couldn't you just set the data item in the tree node to NULL right after deleting the data it used to point to? ... The object that I create is basically a struct and holds some numerical information and a pointer to another object - a 'Worker' object. ... When I retreive my tree's pointer to the deleted Worker, it is not a NULL pointer, but points to what appears to be a valid object (memory location looks normal). ...
    (microsoft.public.vc.mfc)
  • Re: COM + threading ( To Alexander Nickolov )
    ... > First you can't pass the document interface pointer directly to the worker ... You have to marshall them. ... the main thread executes the ... the main thread post back to the worker thread the result of the ...
    (microsoft.public.vc.atl)

Loading