sample code for the EndInvoke method