Decreased async polling delay in ComWrapper
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
- Изменил задержку опроса в ComWrapper.cs с 10мс до 1 мс - Добавил Платформу на уровень 1-1 для наглядности рычага
This commit is contained in:
parent
37e29ce3ab
commit
d95afbe445
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -79,6 +79,9 @@ namespace RR.Common.Controls
|
||||
|
||||
initPort();
|
||||
|
||||
// Отправляем сигнал запуска игры
|
||||
Send("2171");
|
||||
|
||||
// Запускаем асинхронный опрос порта
|
||||
pollCancellationTokenSource = new CancellationTokenSource();
|
||||
StartAsyncPolling();
|
||||
@ -253,6 +256,9 @@ namespace RR.Common.Controls
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
// Отправляем сигнал закрытия игры
|
||||
Send("2170");
|
||||
|
||||
StopAsyncPolling();
|
||||
ClosePort();
|
||||
}
|
||||
@ -273,7 +279,7 @@ namespace RR.Common.Controls
|
||||
while (pollCancellationTokenSource != null &&
|
||||
!pollCancellationTokenSource.Token.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(10, pollCancellationTokenSource.Token); // Опрос каждые 10ms
|
||||
await Task.Delay(1, pollCancellationTokenSource.Token); // Опрос каждые 1ms для уменьшения задержки
|
||||
|
||||
string comInput = await ReadBufferLineAsync(pollCancellationTokenSource.Token);
|
||||
if (!string.IsNullOrEmpty(comInput))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user