Data Transfers and IAsyncOperation

G

Guest

Hello again! :(
I'm trying to implement asynchronous DnD (and Copy/Paste) in a custom NSE:
despite the lack of documentation, I found that i need my DataObject
implement the optional interface IAsyncOperation. I want to always use
asynchronous operations, so I added the following lines to my DataObject
class (I use ATL):

class ATL_NO_VTABLE PPDataObject :
public CComObjectRootEx<CComSingleThreadModel>, public IDataObject, public
IAsyncOperation{
.....
BEGIN_COM_MAP(PPDataObject)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(IAsyncOperation)
END_COM_MAP()
....

STDMETHOD(EndOperation)(HRESULT hResult, IBindCtx* pbcReserved, DWORD
dwEffects){
return S_OK;
}
STDMETHOD(GetAsyncMode)(BOOL* pfIsOpAsync){
return VARIANT_TRUE;
}
STDMETHOD(InOperation)(BOOL *pfInAsyncOp){
*pfInAsyncOp=TRUE;
return S_OK;
}
STDMETHOD(SetAsyncMode)(BOOL fDoOpAsync){
return S_OK;
}
STDMETHOD(StartOperation)(IBindCtx *pbcReserved){
return S_OK;
}
....
}

and I call the DataObject as:

CComObject<PPDataObject>* pDataObject;
//CComObject<>* pAsyncOp;
hr= CComObject<PPDataObject>::CreateInstance(&pDataObject) ;
pDataObject->AddRef();
.....
hr = ::DoDragDrop( pDataObject, pDropSource, DROPEFFECT_MOVE, &dwEffect);
pDropSource->Release();
....

The result is that the operation doesn't occur asynchronously (for big files
doesn't occur at all). I read some opinions which stated that implementing
IAsyncOperation doesn't make Explorer use asynchronous transfers, rather
allows it to... But Explorer always uses asynchronous transfers on my
machine, so I can't understand why I can't force it to even in my NSE!
I need to transer big files, passing first through the network, so a lot of
time can be involved in the process and a synchronous scenario doesn't apply:
Please, can anyone tell me what I'm doing wrong? Wrong interface, wrong
implementation, wrong calls, wrong strategy... ???
Thanks in advance for your help!
 
M

Michael Phillips, Jr.

You may wish to read the following articles:

1) http://msdn2.microsoft.com/en-us/library/aa969396.aspx
2) http://msdn.microsoft.com/msdnmag/issues/1100/wicked/
3) http://www.techvanguards.com/com/concepts/multithreading.asp

Since you are using a background thread to handle the data transfer, the
interface pointers must be marshaled between the threads.

Using CoMarshalInterThreadInterfaceInStream is one solution to try, if you
use the IStream interface for your data. Another is using the
IGlobalInterfaceTable interface.

See the MSDN documentation for the proper use of these interfaces.

Additionally, you may wish to post your question in the PlatformSDK.Shell
newsgroup as that newsgroup handles questions regarding NSE's and the
various Shell Interfaces.
 
G

Guest

Thank you very much, I'll read the articles. Thanks also for the hint about
the PlatformSDK newsgroup! :)
 

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