Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting for delay between command sending #30

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/DCS-BIOS/DCSBIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ public class DCSBIOS : IDisposable
private readonly DcsBiosNotificationMode _dcsBiosNotificationMode;
private volatile bool _isRunning;
private Thread _sendThread;
private const int SEND_COMMANDS_SLEEP = 50;
public int DelayBetweenCommands { get; set; } = 5;

public bool IsRunning
{
get => _isRunning;
}
public bool IsRunning => _isRunning;

public DCSBIOS(string ipFromUdp, string ipToUdp, int portFromUdp, int portToUdp, DcsBiosNotificationMode dcsNotificationMode)
{
Expand Down Expand Up @@ -362,15 +359,15 @@ private void SendCommands()

if (tuple == null)
{
Thread.Sleep(SEND_COMMANDS_SLEEP);
Thread.Sleep(DelayBetweenCommands);
continue;
}

var sender = tuple.Item1;
var dcsbiosCommand = tuple.Item2;
if (dcsbiosCommand == null || dcsbiosCommand.Trim().Length == 0)
{
Thread.Sleep(SEND_COMMANDS_SLEEP);
Thread.Sleep(DelayBetweenCommands);
continue;
}

Expand All @@ -382,7 +379,7 @@ private void SendCommands()
_udpSendClient.Send(asciiBytes.ToArray(), asciiBytes.ToArray().Length, _ipEndPointSenderUdp);

BIOSEventHandler.DCSBIOSCommandWasSent(sender, dcsbiosCommand);
Thread.Sleep(SEND_COMMANDS_SLEEP);
Thread.Sleep(DelayBetweenCommands);
}
catch (OperationCanceledException e)
{
Expand Down
Loading