none
AsyncActionCompletedHandler status

Answers

All replies

  • Hello,

     

    AsyncStatus only return the previous async operator status like Canceled, Completed, Error, Started.

     

    If your ConnectAsync failed with error. The asyncStatus return 3, and it is not the SocketErrorStatus.

     

    The SocketErrorStatus error you should use SocketError.GetStatus  to get is this is static function.

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.socketerror.getstatus.aspx

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 10, 2012 8:47 AM
  • To be sure i understand it correctly, could i do something like this
    AsyncOperationWithProgressCompletedHandler<IBuffer^, uint32> readInfo = ...;
    
    readInfo->Completed = ref new AsyncOperationWithProgressCompletedHandler<IBuffer^, uint32>
        ([=](IAsyncOperationWithProgress<IBuffer^,uint32>^ info, AsyncStatus status)
                {
                    if(info->Status == AsyncStatus::Error)
                    {
                        int errorCode = SocketError::GetStatus();
                        // handle socket error.
                    }
                    else if(info->Status == AsyncStatus::Canceled)
                    {
                        // operation was canceled.
                    }
                    else
                    {
                        // operation success
                        IBuffer^ b = info->GetResults();
                    }
                });

    Thursday, May 10, 2012 3:18 PM
  • Hello,

    You should use asyncStatus==AsyncStatus::Error to get the error result.

    if(asyncStatus==AsyncStatus::Error)
                {
                    try
                    {
                        int res= info->GetResults();

                    }catch(Exception^ ex)
                    {
                     
                    }
                }

    You can also use try-catch block in the task.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 17, 2012 8:06 AM