I am currently responsible for one of our web tools to copy products between different shares. Everything works fine until now, but now I have a little problem. There is a specific Product type that is very big (about 30 GB). Since this type of jobs doesn't occur very often and the robocopy job works fine, we decided to start the asynchronous task for this specific type.
This is the working action for the normal Packages:
public JsonResult MovepackagetoMaster(string packagename, CopyStructure structure)
{
Robocopy2.WSPackaging objPayRef = new Robocopy2.WSPackaging();
objPayRef.UseDefaultCredentials = true;
var CopyStatusInfo = objPayRef.MovePackageToMaster(packagename, structure);
return Json(CopyStatusInfo.RobocopyError, JsonRequestBehavior.AllowGet);
}
Now I tried to make a second action which runs asynchronously, but I keep getting errors. My current state looks like that:
public async System.Threading.Tasks.Task<JsonResult> MovepackagetoMaster2(string packagename, CopyStructure structure)
{
Robocopy2.WSPackaging objPayRef = new Robocopy2.WSPackaging();
objPayRef.UseDefaultCredentials = true;
var CopyStatusInfo = await objPayRef.MovePackageToMasterAsync(packagename, structure);
return Json(CopyStatusInfo.RobocopyError, JsonRequestBehavior.AllowGet);
}
The current error is cannot await void
Can someone here help me how to run this job asynchronously?
The async version of that task wasn't designed by me but currently they look like that:
public RequestResult MovePackageToMaster(string package, CopyStructure structure) {
object[] results = this.Invoke("MovePackageToMaster", new object[] {
package,
structure});
return ((RequestResult)(results[0]));
}
/// <remarks/>
public void MovePackageToMasterAsync(string package, CopyStructure structure) {
this.MovePackageToMasterAsync(package, structure, null);
}
/// <remarks/>
public void MovePackageToMasterAsync(string package, CopyStructure structure, object userState) {
if ((this.MovePackageToMasterOperationCompleted == null)) {
this.MovePackageToMasterOperationCompleted = new System.Threading.SendOrPostCallback(this.OnMovePackageToMasterOperationCompleted);
}
this.InvokeAsync("MovePackageToMaster", new object[] {
package,
structure}, this.MovePackageToMasterOperationCompleted, userState);
}