How to handle the class IBuffer in my interface
-
mercredi 28 mars 2012 10:45
Hi: all
I want to write a Ansync ReadData API like the ReadAsync API of IInputStream,
Windows::Foundation::IAsyncOperationWithProgress<Windows::Storage::Streams::IBuffer^, unsigned int>^ ReadAsync(Windows::Storage::Streams::IBuffer^ buffer, unsigned int count, Windows::Storage::Streams::InputStreamOptions options)
I want to send the byte data to the caller of this Ansync Read API, But I do not know how to use the parameter "IBuffer^buffer",
Below is my codes of the API :
IAsyncOperationWithProgress<IBuffer^, unsigned int>^ INetworkIORandomAccessStream::ReadAsync(IBuffer^ buffer, unsigned int count, InputStreamOptions options) { return create_async([this](progress_reporter<unsigned int> progress) { //How to send the byte data in this case //return (IBuffer^)buffer; }); }Please give me some help . Thanks
Toutes les réponses
-
mercredi 28 mars 2012 20:36Modérateur
Hi Pitt.Chen,
To access the data in the buffer query the IBuffer for its IBufferByteAccess interface.
--Rob
- Proposé comme réponse Rob CaplanMicrosoft Employee, Moderator mercredi 28 mars 2012 20:36
- Marqué comme réponse Jesse JiangMicrosoft Contingent Staff, Moderator lundi 9 avril 2012 01:35
-
jeudi 29 mars 2012 10:53Modérateur
Hello,
We can not return two value in IAsyncOperationWithProgress. You can use int* to get the int return value, and the unsigned int should be uint32 in C++/CX. Please follow these codes:
// In .h file using namespace Windows::Storage::Streams; Windows::Foundation::IAsyncActionWithProgress <IBuffer^>^ ReadAsync(IBuffer^ buffer, unsigned int count, InputStreamOptions options,int* outcount); // In .cpp file using namespace Windows::Foundation; using namespace Windows::Foundation::Collections; using namespace Concurrency; IAsyncActionWithProgress<IBuffer^>^ WinRTComponent::ReadAsync( IBuffer^ buffer, unsigned int count, InputStreamOptions options, int* outcount) { return create_async([this](progress_reporter<IBuffer^> progress) { //How to send the byte data in this case //return (IBuffer^)buffer; }); }
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
- Marqué comme réponse Jesse JiangMicrosoft Contingent Staff, Moderator lundi 9 avril 2012 01:35

