Возвращение полной работоспособности

This commit is contained in:
2025-02-22 10:06:41 +03:00
parent 348947fb4c
commit b6226b68c9
4 changed files with 19 additions and 6 deletions
+1
View File
@@ -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));
+1 -1
View File
@@ -4,6 +4,6 @@ namespace mROA.Abstract
{
public interface IRequestExtractor : IInjectableModule
{
Task StartExtraction();
Task StartExtraction();
}
}
@@ -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();
}
}
}
}