protected DataTransport(IChannelFactory <TPacket> channelFactory, DataTransportSettings setting, ILogger log) { Log = log; Settings = setting; ChannelFactory = channelFactory; InnerChannels = new ObservableCollection <IChannel <TPacket> >(); Channels = new ReadOnlyObservableCollection <IChannel <TPacket> >(InnerChannels); if (setting.AutoCheckIsOpen) { _tokenSource = new CancellationTokenSource(); _checkingIsOpenedTask = Task.Factory.StartNew(async() => { var token = _tokenSource.Token; while (!token.IsCancellationRequested) { try { if (IsOpenCore != IsOpen) { IsOpen = IsOpenCore; } await Task.Delay(Settings.AutoCheckIsOpenTime, token); } catch (OperationCanceledException) { break; } catch (Exception) { await Task.Delay(1000); } } }); } }
protected DataTransport(IChannelFactory <TPacket> channelFactory, DataTransportSettings setting) : this(channelFactory, setting, NullLoggerProvider.Instance.CreateLogger("DataTransport")) { }