I have an ASP.NET MVC 3 action method that accepts HttpFileCollectionBasean HTTP POST.
In this method, I need to resize and upload the image 3 times.
Currently, the action method is as follows:
public ActionResult ChangeProfilePicture()
{
var fileUpload = Request.Files[0];
ResizeAndUpload(fileUpload.InputStream, Size.Original);
ResizeAndUpload(fileUpload.InputStream, Size.Profile);
ResizeAndUpload(fileUpload.InputStream, Size.Thumb);
return Content("Success", "text/plain");
}
This is basically a user profile page where they change their pic profile. Downloading takes place through jQuery AJAX.
Now, how can I turn off the three calls ResizeAndUploadas asynchronous tasks, but not return the result of the action until all three tasks are completed?
I used Task.Factory.StartNewto run asynchronous tasks, but that was when I did not care about waiting for the result.
Any ideas?