private async Task ReceivedCommunicationSetupJob(Memory <byte> buffer) { var data = S7CommSetupDatagram.TranslateFromMemory(buffer); using (var dg = S7CommSetupAckDataDatagram .TranslateToMemory( S7CommSetupAckDataDatagram .BuildFrom(_s7Context, data), out var memoryLength)) { using (var sendData = _transport.Build(dg.Memory.Slice(0, memoryLength), out var sendLength)) { var result = await _transport.Client.SendAsync(sendData.Memory.Slice(0, sendLength)).ConfigureAwait(false); if (result == SocketError.Success) { //UpdateConnectionState(ConnectionState.PendingOpenPlc); _s7Context.MaxAmQCalling = data.Parameter.MaxAmQCalling; _s7Context.MaxAmQCalled = data.Parameter.MaxAmQCalling; _s7Context.PduSize = data.Parameter.PduLength; if (_concurrentJobs != null) { _concurrentJobs.Dispose(); } _concurrentJobs = new SemaphoreSlim(_s7Context.MaxAmQCalling); await UpdateConnectionState(ConnectionState.Opened).ConfigureAwait(false); } } } }
private Task ReceivedCommunicationSetupJob(Memory <byte> buffer) { var data = S7CommSetupDatagram.TranslateFromMemory(buffer); Task.Run(() => HandleCommSetupAsync(data).ConfigureAwait(false)); return(Task.CompletedTask); }