0

I am trying to pass in some data to the continuation method once UploadAsync finishes. I can read the AsyncState from withing the method, but I don't know how to set it from outside?

Here is a sample of what I have so far:

Action<Task<IUploadProgress>> myAction = (input) => 
{
  object asyncState = input.AsyncState;
  IUploadProgress result = input.Result;
};

Task<IUploadProgress> uploadTask = service.Objects.Insert(myObject, bucketName, stream, "").UploadAsync();

uploadTask.ContinueWith(myAction);

uploadTask.Wait();

Thanks.

1 Answers1

0

I'll do something like the following:

var insertMediaReq = service.Objects.Insert(myObject, bucketName, stream, "");
Task<IUploadProgress> uploadTask = insertMediaReq.UploadAsync();
uploadTask.ContinueWith(t => 
{
  // Here you can use t.Result. 
  // But I don't get it. what are you trying to do here?
});
peleyal
  • 3,472
  • 1
  • 14
  • 25