private void Window_Loaded(object sender, RoutedEventArgs e) { this.plcServer = new PlcServer(this.loggerFactory, IPAddress.Any, PORT); this.plcServer.Start(); this.LogMessage(string.Format( CultureInfo.CurrentCulture, "正在监听 {0} 端口,等待 PLC 连接,PLC 连接上来后会在这里收到通知。", PORT)); this.cancellationTokenSource = new CancellationTokenSource(); this.backgroundTask = Task.Run(this.BackgroundTaskEntryPoint, this.cancellationTokenSource.Token); }
public PlcManager(ILogger <PlcManager> logger, PlcServer plcServer) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.plcServer = plcServer ?? throw new ArgumentNullException(nameof(plcServer)); }