Возвращение полной работоспособности
This commit is contained in:
@@ -69,6 +69,7 @@ class Program
|
||||
Console.WriteLine(string.Join(", ", names));
|
||||
|
||||
var page = printer.Value.Print("Test Page", new CancellationToken()).GetAwaiter().GetResult();
|
||||
Console.WriteLine("Page printed");
|
||||
var data = page.Value.GetData();
|
||||
Console.WriteLine("Data : {0}", Encoding.UTF8.GetString(data));
|
||||
|
||||
|
||||
@@ -41,10 +41,12 @@ namespace mROA.Implementation.Backend
|
||||
|
||||
if (currentCommand.ReturnType.BaseType == typeof(Task) &&
|
||||
currentCommand.ReturnType.GenericTypeArguments.Length == 1)
|
||||
return TypedExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo, representationModule);
|
||||
return TypedExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo,
|
||||
representationModule);
|
||||
|
||||
if (currentCommand.ReturnType == typeof(Task))
|
||||
return ExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo, representationModule);
|
||||
return ExecuteAsync(currentCommand, context, parameter, command, _cancellationRepo,
|
||||
representationModule);
|
||||
|
||||
return Execute(currentCommand, context, parameter, command);
|
||||
}
|
||||
@@ -76,7 +78,8 @@ namespace mROA.Implementation.Backend
|
||||
}
|
||||
|
||||
private static ICommandExecution ExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
|
||||
ICallRequest command, ICancellationRepository cancellationRepository, IRepresentationModule representationModule)
|
||||
ICallRequest command, ICancellationRepository cancellationRepository,
|
||||
IRepresentationModule representationModule)
|
||||
{
|
||||
var tokenSource = new CancellationTokenSource();
|
||||
cancellationRepository.RegisterCancellation(command.Id, tokenSource);
|
||||
@@ -96,14 +99,17 @@ namespace mROA.Implementation.Backend
|
||||
Id = command.Id,
|
||||
CommandId = command.CommandId
|
||||
};
|
||||
var multiClientOwnershipRepository =
|
||||
TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository;
|
||||
multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id);
|
||||
representationModule.PostCallMessage(command.Id, MessageType.FinishedCommandExecution, payload);
|
||||
multiClientOwnershipRepository?.FreeOwnership();
|
||||
}, token);
|
||||
|
||||
return new AsyncCommandExecution
|
||||
{
|
||||
Id = command.Id, CommandId = command.CommandId
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -116,7 +122,8 @@ namespace mROA.Implementation.Backend
|
||||
}
|
||||
|
||||
private static ICommandExecution TypedExecuteAsync(MethodInfo currentCommand, object context, object? parameter,
|
||||
ICallRequest command, ICancellationRepository cancellationRepository, IRepresentationModule representationModule)
|
||||
ICallRequest command, ICancellationRepository cancellationRepository,
|
||||
IRepresentationModule representationModule)
|
||||
{
|
||||
var tokenSource = new CancellationTokenSource();
|
||||
cancellationRepository.RegisterCancellation(command.Id, tokenSource);
|
||||
@@ -140,7 +147,11 @@ namespace mROA.Implementation.Backend
|
||||
CommandId = command.CommandId,
|
||||
Type = finalResult?.GetType()
|
||||
};
|
||||
var multiClientOwnershipRepository =
|
||||
TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository;
|
||||
multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id);
|
||||
representationModule.PostCallMessage(command.Id, MessageType.FinishedCommandExecution, payload);
|
||||
multiClientOwnershipRepository?.FreeOwnership();
|
||||
}, token);
|
||||
|
||||
return new AsyncCommandExecution
|
||||
|
||||
@@ -99,5 +99,6 @@ namespace mROA.Implementation.Frontend
|
||||
multiClientOwnershipRepository?.FreeOwnership();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user