Skip to content

Commit dd31a7a

Browse files
authored
removing some stuff (#160)
1 parent 698ec3a commit dd31a7a

4 files changed

Lines changed: 17 additions & 97 deletions

File tree

cas-dotnet-sdk/CASConfiguration.cs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ public static string ApiKey
4141
{
4242
Task osSendTask = SendOSInformation(value);
4343
Task dhTask = DiffieHellmanExchange.CreateSharedSecretWithServer();
44-
_IsThreadProductEnabled = new IsThreadingProductEnabled();
45-
Task isThreadingEnabledTask = _IsThreadProductEnabled.ValidateThreadingProductSubscription();
46-
Task.WhenAll(osSendTask, dhTask, isThreadingEnabledTask).GetAwaiter().GetResult();
44+
Task.WhenAll(osSendTask, dhTask).GetAwaiter().GetResult();
4745
}
4846
else
4947
{
@@ -108,54 +106,6 @@ internal static DiffieHellmanExchange DiffieHellmanExchange
108106
get { return _DiffieHellmanExchange; }
109107
set { _DiffieHellmanExchange = value; }
110108
}
111-
112-
private static IsThreadingProductEnabled _IsThreadProductEnabled;
113-
internal static IsThreadingProductEnabled IsThreadProductEnabled
114-
{
115-
get { return _IsThreadProductEnabled; }
116-
set { _IsThreadProductEnabled = value; }
117-
}
118-
119-
private static bool _IsThreadingEnabled = IsThreadingEnabledChecker().GetAwaiter().GetResult();
120-
internal static bool IsThreadingEnabled
121-
{
122-
get { return _IsThreadingEnabled; }
123-
set { _IsThreadingEnabled = value; }
124-
}
125-
126-
private static async Task<bool> IsThreadingEnabledChecker()
127-
{
128-
bool result = true;
129-
if (!await IsRunningInTestMode())
130-
{
131-
result = false;
132-
}
133-
return result;
134-
}
135-
136-
137-
/// <summary>
138-
/// Used to determine if the project is being run from xunit so specific things wont fail
139-
/// due to running the SDK in test mode.
140-
/// </summary>
141-
/// <returns></returns>
142-
private static async Task<bool> IsRunningInTestMode()
143-
{
144-
var stackTrace = new StackTrace();
145-
foreach (var frame in stackTrace.GetFrames())
146-
{
147-
var method = frame.GetMethod();
148-
if (method != null && method.DeclaringType != null)
149-
{
150-
var assembly = method.DeclaringType.Assembly;
151-
if (assembly.FullName.StartsWith("xunit"))
152-
{
153-
return true;
154-
}
155-
}
156-
}
157-
return false;
158-
}
159109
private static async Task SendOSInformation(string apiKey)
160110
{
161111
OperatingSystemDeterminator osd = new OperatingSystemDeterminator();

cas-dotnet-sdk/Queues/BenchmarkSenderRetryQueue.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Concurrent;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using System.Threading;
78
using System.Threading.Tasks;
89

@@ -37,19 +38,27 @@ private async void CheckQueueForRequestsToSend(object state)
3738
await Task.Run(async () =>
3839
{
3940
List<BenchmarkMacAddressSDKMethod> addBackToQueue = new List<BenchmarkMacAddressSDKMethod>();
41+
BenchmarkSender newSender = new BenchmarkSender();
42+
List<Tuple<Task<bool>, BenchmarkMacAddressSDKMethod>> requestSuccess = new();
4043
foreach (BenchmarkMacAddressSDKMethod method in this.Queue)
4144
{
4245
BenchmarkMacAddressSDKMethod retryBnechmark = null;
4346
if (this.Queue.TryDequeue(out retryBnechmark))
4447
{
45-
BenchmarkSender newSender = new BenchmarkSender();
46-
bool result = await newSender.SendNewBenchmarkMethodRetry(retryBnechmark);
47-
if (!result)
48-
{
49-
addBackToQueue.Add(retryBnechmark);
50-
}
48+
var tuple = new Tuple<Task<bool>, BenchmarkMacAddressSDKMethod>(newSender.SendNewBenchmarkMethodRetry(retryBnechmark), retryBnechmark);
49+
requestSuccess.Add(tuple);
5150
}
5251
}
52+
53+
bool[] results = await Task.WhenAll(requestSuccess.ToList().Select(x => x.Item1));
54+
for (int i = 0; i < results.Length; i++)
55+
{
56+
if (!results[i])
57+
{
58+
addBackToQueue.Add(requestSuccess[i].Item2);
59+
}
60+
}
61+
5362
// Check if any failed and place back into queue
5463
if (addBackToQueue.Count > 0)
5564
{
@@ -59,7 +68,6 @@ await Task.Run(async () =>
5968
if (method.NumberOfTries > 2)
6069
{
6170
this.Enqueue(method);
62-
6371
}
6472
}
6573
}

cas-dotnet-sdk/Queues/IsThreadingProductEnabled.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

cas-dotnet-sdk/cas-dotnet-sdk.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
77
<Title>cas-dotnet-sdk</Title>
88
<PackageIcon>icon.jpeg</PackageIcon>
9-
<Version>1.5.8</Version>
9+
<Version>1.5.9</Version>
1010
<Authors>Mike Mulchrone</Authors>
1111
<Description>A Nuget package that provides a implementation of the RustCrypto suite of cryptographic algorithms.</Description>
1212
<RepositoryUrl>https://github.com/Cryptographic-API-Services/cas-dotnet-sdk</RepositoryUrl>

0 commit comments

Comments
 (0)