public void SetGoalReachedCallback(Action <int, GalileoStatus> goalCB) { onGoalReachedCB = (goalid, statusJson, length) => { byte[] result = new byte[length]; Marshal.Copy(statusJson, result, 0, (int)length); var statusStr = Encoding.ASCII.GetString(result, 0, (int)length); goalCB?.Invoke(goalid, JsonConvert.DeserializeObject <GalileoStatus>(statusStr)); }; GalileoFunctions.SetGoalReachedCallback(instance, onGoalReachedCB); }