locked
When I access the pictures of foler"my pictures" second time , my application is breakDown!

    Question

  • After  access Images at one Page(Use IRandomAccessStream), then I navigate to another Page. Then access the images of the same folder. Then my application is breakdowned!  Who can tell me why?  Here is my data in one page:

      

    create_task(KnownFolders::PicturesLibrary->GetFolderAsync(folderName)).then([this](StorageFolder^ folder)
    {
    if (folder != nullptr)
            {
    //Platform::String^ folderPath = folder->Path;
    _items = ref new Platform::Collections::Vector<Item^>();
    auto getFilesTask = create_task(folder->GetFilesAsync());
    getFilesTask.then( [folder](IVectorView<StorageFile^>^ files) 
    {
    std::for_each(begin(files), end(files), [files](StorageFile^ file)
                    {
    if (file)
                    {
    create_task(file->OpenAsync(Windows::Storage::FileAccessMode::Read)).then([file](IRandomAccessStream^ fileStream)
                  {
                 auto bitmapImage = ref new BitmapImage();
                 bitmapImage->SetSource(fileStream);
     item = ref new Item();
     item->Image = bitmapImage;
      _items->Append(item);

    });


                    }

                    });

    });
      DownGridView->ItemsSource = _items;//怎样让getFilesTask.then执行完之后再执行这一句呢? 就是怎样在这句话前面等待呢?
    }
    });

    and here is my data of another page:

    when I use bitmapImage  as my ImageSource in other method . My application breakdown !  This situation will be happened after read the same folder twice.


    Wednesday, June 05, 2013 11:35 AM