private async Task LocalExecuteAsync(ServiceEntity entry, RemoteInvokeMessage remoteInvokeMessage, RemoteInvokeResultMessage resultMessage) { try { var result = await entry.Func(remoteInvokeMessage.Parameters); var task = result as Task; if (task == null) { resultMessage.Result = result; } else { task.Wait(); var taskType = task.GetType().GetTypeInfo(); if (taskType.IsGenericType) { resultMessage.Result = taskType.GetProperty("Result").GetValue(task); } } } catch (Exception exception) { Console.WriteLine(exception); resultMessage.ExceptionMessage = GetExceptionMessage(exception); } }
private async Task LocalExecuteAsync(ServiceEntity entry, RemoteInvokeMessage remoteInvokeMessage, RemoteInvokeResultMessage resultMessage) { try { var result = await entry.Func(remoteInvokeMessage.Parameters); var task = result as Task; if (task == null) { resultMessage.Result = result; } else { task.Wait(); var taskType = task.GetType().GetTypeInfo(); if (taskType.IsGenericType) { resultMessage.Result = taskType.GetProperty("Result")?.GetValue(task); } } } catch (Exception exception) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError("执行本地逻辑时候发生了错误", exception); } resultMessage.ExceptionMessage = GetExceptionMessage(exception); } }