operation->GetResults() get null pointer!!
-
Thursday, April 12, 2012 1:26 PM
Hi all:
I use WRL method for file access.
However, now I usually OpenAsync() failed.
Because [operation->GetResults(&PanoramaFile)] usually get null pointer. (Sometimes it's ok!)
The code is as below.
(The full code http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/f79d829f-8445-454a-b8d6-83cc3bc6b615)
===========================================================================================
HString hstrFileName;
hstrFileName.Set(L"sample.txt");// Call CreteFileAsync
__FIAsyncOperation_1_Windows__CStorage__CStorageFile_t * operation;hr = pStorageFolder->CreateFileAsync(hstrFileName.Get(),
CreationCollisionOption::CreationCollisionOption_ReplaceExisting,
&operation);
if (FAILED(hr))
{
::Microsoft::WRL::Details::RaiseException(hr);
}
operation->GetResults(&PanoramaFile);__RPC__deref_out_opt __FIAsyncOperation_1_Windows__CStorage__CStreams__CIRandomAccessStream *RandomStream;
PanoramaFile->OpenAsync(FileAccessMode_ReadWrite, &RandomStream);
===========================================================================================
All Replies
-
Thursday, April 12, 2012 10:27 PMModerator
The problem is that the results aren't ready. CreateFileAsync is an asynchronous function and will take some time to complete. You cannot get the results until it has completed.
See Asynchronous programming in C++ for more information on how to handle asynchronous calls.
--Rob
- Proposed As Answer by Jesse JiangMicrosoft Contingent Staff, Moderator Friday, April 13, 2012 2:50 AM
- Marked As Answer by Steve HorneMicrosoft Employee, Moderator Tuesday, April 24, 2012 11:53 PM


