This problem requires two step solution.
First you need to invoke the CalculateRollupField either via JS or C#.
For your requirement, since you need to see the results immediately, I suggest use JavaScript.
The following JS code will trigger your roll up field recalculation
function CalculateRollupField(EntityName, recGuid, RollUpFieldName)
{
recGuid = recGuid.replace("{", "").replace("}", ""); // String Guid
var HttpReq = new XMLHttpRequest();
HttpReq.open(this.method, this.url, true); // Need this to initiate the request
HttpReq.setRequestHeader("OData-Version", "4.0");
HttpReq.setRequestHeader("OData-MaxVersion", "4.0");
// Double Check your API URL, may differ for v9.0
HttpReq.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/" + "CalculateRollupField(Target=@p1,FieldName=@p2)?" + "@p1={'@odata.id':'" + EntityName + "(" + recGuid + ")'}&" + "@p2='" + RollUpFieldName + "'", true);
HttpReq.onreadystatechange = function ()
{
if (this.readyState === 4)
{
HttpReq.onreadystatechange = null;
if (this.status === 200)
{
var results = JSON.parse(this.response);
}
else
{
Xrm.Utility.alertDialog(this.statusText);
}
}
};
HttpReq.send(JSON.stringify({}));
}
// You can then retrieve the updated value via JS API call (or fetchXML) & use XRM commands to replace the updated value in the form to display it to user right away