Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

Data Transfers and IAsyncOperation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JDavide - 28 Mar 2007 01:04 GMT
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!
Michael Phillips, Jr. - 28 Mar 2007 16:18 GMT
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.

> Hello again! :(
> I'm trying to implement asynchronous DnD (and Copy/Paste) in a custom NSE:
[quoted text clipped - 57 lines]
> implementation, wrong calls, wrong strategy... ???
> Thanks in advance for your help!
JDavide - 30 Mar 2007 10:28 GMT
Thank you very much, I'll read the articles. Thanks also for the hint about
the PlatformSDK newsgroup! :)

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.