diff --git a/YaNco.sln.DotSettings b/YaNco.sln.DotSettings
index 5d780378..47b88b5a 100644
--- a/YaNco.sln.DotSettings
+++ b/YaNco.sln.DotSettings
@@ -1,3 +1,6 @@
+ True
+ True
+ True
<data><IncludeFilters /><ExcludeFilters><Filter ModuleMask="SAPSystemTests" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="YaNco.Core.Tests" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /></ExcludeFilters></data>
True
\ No newline at end of file
diff --git a/src/YaNco.Core/Connection.cs b/src/YaNco.Core/Connection.cs
index b4a81ee5..16dae8a3 100644
--- a/src/YaNco.Core/Connection.cs
+++ b/src/YaNco.Core/Connection.cs
@@ -13,7 +13,6 @@ public class Connection : IConnection
public IRfcRuntime RfcRuntime { get; }
private readonly IAgent> _stateAgent;
public bool Disposed { get; private set; }
- private bool _functionCalled;
public Connection(
IConnectionHandle connectionHandle,
@@ -50,17 +49,13 @@ public Connection(
case InvokeFunctionMessage invokeFunctionMessage:
{
- _functionCalled = true;
- StartWaitForFunctionCancellation(invokeFunctionMessage.CancellationToken);
- try
+ using (var callContext = new FunctionCallContext())
{
+ StartWaitForFunctionCancellation(callContext, invokeFunctionMessage.CancellationToken);
var result = rfcRuntime.Invoke(handle, invokeFunctionMessage.Function.Handle)
.Map(u => (object) u);
return (handle, result);
- }
- finally
- {
- _functionCalled = false;
+
}
}
@@ -141,20 +136,20 @@ public EitherAsync Cancel()
return res;
}
- private async void StartWaitForFunctionCancellation(CancellationToken token)
+ private async void StartWaitForFunctionCancellation(FunctionCallContext context, CancellationToken token)
{
// ReSharper disable once MethodSupportsCancellation
- await Task.Run(() =>
+ await Task.Factory.StartNew(() =>
{
- while (!token.IsCancellationRequested && _functionCalled)
+ while (!token.IsCancellationRequested && !context.Exited)
{
- if(token.WaitHandle.WaitOne(1000))
+ if(token.WaitHandle.WaitOne(500,true))
break;
}
- }).ConfigureAwait(false);
+ }, TaskCreationOptions.LongRunning).ConfigureAwait(false);
- if (token.IsCancellationRequested && _functionCalled)
+ if (token.IsCancellationRequested && !context.Exited)
await Cancel().ToEither().ConfigureAwait(false);
}
@@ -230,5 +225,15 @@ public void Dispose()
_stateAgent.Tell(new DisposeMessage(RfcErrorInfo.EmptyResult()));
}
+
+ private class FunctionCallContext : IDisposable
+ {
+ public bool Exited { get; private set; }
+ public void Dispose()
+ {
+ Exited = true;
+ }
+ }
}
+
}
diff --git a/src/YaNco.Core/YaNco.Core.csproj b/src/YaNco.Core/YaNco.Core.csproj
index fff0bdcd..d9295be5 100644
--- a/src/YaNco.Core/YaNco.Core.csproj
+++ b/src/YaNco.Core/YaNco.Core.csproj
@@ -9,7 +9,7 @@ This package contains the core implementation.
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/test/SAPSystemTests/Program.cs b/test/SAPSystemTests/Program.cs
index f9148219..4c034d4a 100644
--- a/test/SAPSystemTests/Program.cs
+++ b/test/SAPSystemTests/Program.cs
@@ -60,7 +60,7 @@ static async Task Main(string[] args)
var connectionBuilder = new ConnectionBuilder(settings)
.WithStartProgramCallback(callback)
- .ConfigureRuntime(c =>
+ .ConfigureRuntime(c =>
c.WithLogger(new SimpleConsoleLogger()));
using (var context = new RfcContext(connectionBuilder.Build()))
@@ -126,7 +126,7 @@ private static async Task RunIntegrationTest01(IRfcContext context)
QUAN = 99.123,
RAW = RandomByteArray(10),
SSTRING = RandomString(10),
- TIMS = default(DateTime).Add(new TimeSpan(23, 59,59)),
+ TIMS = default(DateTime).Add(new TimeSpan(23, 59, 59)),
STRING = "ABCDE",
RAWSTRING = RandomByteArray(300),
UNIT = "ABC"
@@ -188,7 +188,7 @@ from fieldUNIT in s.GetField("FIELD_UNIT")
// ReSharper restore InconsistentNaming
// ReSharper restore IdentifierTypo
- select new TypesTestData
+ select new TypesTestData
{
ACCP = fieldACCP,
CHAR = fieldCHAR,
@@ -300,8 +300,8 @@ private static async Task RunIntegrationTest02(IRfcContext context)
var outputData = await context.CallFunction("ZYANCO_IT_1",
- Input: f => f.SetStructure("IS_IN", es =>
- es.Bind(s=>s.SetFromDictionary(outputDictionary))),
+ Input: f => f.SetStructure("IS_IN", es =>
+ es.Bind(s => s.SetFromDictionary(outputDictionary))),
Output: f => f.MapStructure("ES_ECHO", s =>
// ReSharper disable InconsistentNaming
@@ -368,14 +368,14 @@ from fieldUNIT in s.GetField("FIELD_UNIT")
// ReSharper restore StringLiteralTypo
- var compareLogic = new CompareLogic(new ComparisonConfig(){MaxDifferences = int.MaxValue});
+ var compareLogic = new CompareLogic(new ComparisonConfig() { MaxDifferences = int.MaxValue });
var result = compareLogic.Compare(inputData, outputData);
Console.WriteLine(!result.AreEqual ? result.DifferencesString : "Test succeed");
}
- private static async Task RunPerformanceTest01(IRfcContext context, int rows=0)
+ private static async Task RunPerformanceTest01(IRfcContext context, int rows = 0)
{
var watch = Stopwatch.StartNew();
@@ -385,7 +385,7 @@ private static async Task RunPerformanceTest01(IRfcContext context, int ro
from char40 in s.GetField("FIELD_CHAR40")
from char01 in s.GetField("FIELD_CHAR01")
from int04 in s.GetField("FIELD_INT4")
- //from s in s.GetField("FIELD_STRING")
+ //from s in s.GetField("FIELD_STRING")
select new TestData
{
@@ -462,7 +462,7 @@ public class TestData
public int Int04 { get; set; }
public string String { get; set; }
-
+
}
public class TypesTestData
diff --git a/test/SAPSystemTests/Properties/launchSettings.json b/test/SAPSystemTests/Properties/launchSettings.json
index aeebe485..076b233c 100644
--- a/test/SAPSystemTests/Properties/launchSettings.json
+++ b/test/SAPSystemTests/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"SAPSystemTests": {
"commandName": "Project",
- "commandLineArgs": "/tests:repeats=2 /tests:rows=0",
+ "commandLineArgs": "/tests:repeats=100000 /tests:rows=0",
"nativeDebugging": true
}
}