locked
How reliable is loadasync ?

    Question

  • I have had trouble with a games app crashing on certification.

    On my pc it worked fine passing WACK 3.1.

    I tried the app on Windows simulator and touch and it worked fine.

    I later tried it again on Windows simulator using keyboard and when the  man hit a flashing object instead of sound the app just hung.

    I noticed in my software that I wasn't handling a loadasync fail.

    When I handled it my software stopped locking up. On my PC the problem never occurred using the app from Visual Studio.

    So it looks like loadasync occasionally fails and causes an exception. If this isn't handled properly the software will lock up waiting for the file to load.


    n.Wright

    Saturday, October 05, 2013 12:28 AM

Answers

All replies

  • Which LoadAsync? There are LoadAsync settings on several different classes.

    I'm not sure that matters, actually. Any file access can fail and so error checking shouldn't be skipped.

    --Rob

    Saturday, October 05, 2013 12:49 AM
    Owner
  • I was loading in a file using loadasync but didn't catch a failure properly.


    n.Wright

    Saturday, October 05, 2013 11:07 AM
  • Here is my load routine.

    I have routine that checks if the file exists first and if it does uses this routine to load the file.

    void Renderer::loadgame()
    {
    		String^ fileName="arnold2.pcb"; 
    	
    	StorageFolder^ item = KnownFolders::PicturesLibrary;
    
    	auto getFileOp = item->GetFileAsync(fileName);
    	getFileOp->Completed = ref new AsyncOperationCompletedHandler<StorageFile^>
        ([=](IAsyncOperation<StorageFile^>^ operation, AsyncStatus status)
      {
        auto storageFile = operation->GetResults();
    	auto openOp = storageFile->OpenAsync(FileAccessMode::Read);
        openOp->Completed = 
          ref new AsyncOperationCompletedHandler <IRandomAccessStream^>
          ([=](IAsyncOperation<IRandomAccessStream^>^ operation, AsyncStatus status)
        {
          auto istream = operation->GetResults();
          auto dr = ref new DataReader(istream);
          auto loadOp = dr->LoadAsync(istream->Size);
          loadOp->Completed = ref new AsyncOperationCompletedHandler<UINT>
            ([=](IAsyncOperation<UINT>^ operation, AsyncStatus status)
          {
    
    		    auto bytesRead = operation->GetResults();
    			
    			time=(UINT32)(dr->ReadUInt32());
    			screennumber=(UINT32)(dr->ReadUInt32());
    			fallheight=(UINT32)(dr->ReadUInt32());
    			screennumber=(UINT32)(dr->ReadUInt32());
    			lives=(UINT32)(dr->ReadUInt32());
    			arnoldx=(UINT32)(dr->ReadUInt32());
    			arnoldy=(UINT32)(dr->ReadUInt32());
    			mode=(UINT32)(dr->ReadUInt32());
    			direction=(UINT32)(dr->ReadUInt32());
    			jumpkeypressed=(UINT32)(dr->ReadUInt32());
    			fallingq=(UINT32)(dr->ReadUInt32());
    			jumpheight=(UINT32)(dr->ReadUInt32());
    			
    			
    			dr->DetachStream();
    			
    		try{
    	operation->GetResults();		//Get the result of task by forcing it.
    		gameloaded=3;
    		}
    		  catch(...)
    		  {
    			  gameloaded=0;
    			  return;
    		  }
    
    	  });
        });
      });
    
    	
    			  
    }
    
    
    


    n.Wright

    Saturday, October 05, 2013 8:40 PM