Windows.Networking.BackgroundTransfer.UploadOperation.StartAsync C# (CSharp) Méthode

StartAsync() public méthode

public StartAsync ( ) : UploadOperation>.IAsyncOperationWithProgress
Résultat UploadOperation>.IAsyncOperationWithProgress
		public extern IAsyncOperationWithProgress<UploadOperation, UploadOperation> StartAsync();
		public extern IAsyncOperationWithProgress<UploadOperation, UploadOperation> AttachAsync();

Usage Example

        private async Task HandleUploadAsync(UploadOperation upload, bool start)
        {
            try
            {
                CancellationTokenSource cts = new CancellationTokenSource();
                Progress<UploadOperation> progressCallback = new Progress<UploadOperation>();
                if (start)
                {
                    // Start the upload and attach a progress handler.
                    await upload.StartAsync().AsTask(cts.Token, progressCallback);
                }
                else
                {
                    // The upload was already running when the application started, re-attach the progress handler.
                    await upload.AttachAsync().AsTask(cts.Token, progressCallback);
                }

                ResponseInformation response = upload.GetResponseInformation();
                //  Log(String.Format("Completed: {0}, Status Code: {1}", upload.Guid, response.StatusCode));
            }
            catch (TaskCanceledException)
            {
                // Log("Upload cancelled.");
            }
            catch (Exception ex)
            {
                //LogException("Error", ex);
            }
        }
All Usage Examples Of Windows.Networking.BackgroundTransfer.UploadOperation::StartAsync