Esempio n. 1
0
 private static void _port_ConnectionStatusChanged0(object sender, MonoSerialPort.ConnectionStatusChangedEventArgs args)
 {
     //var port = (sender as MonoSerialPort.SerialPortInput);
     System.Console.WriteLine("{1} Status:-> {0}", args.Connected, portRC);
 }
 private static void _port_ConnectionStatusChanged(object sender, MonoSerialPort.ConnectionStatusChangedEventArgs args)
 {
     System.Console.WriteLine("Status:-> {0}", args.Connected);
 }
Esempio n. 3
0
        //private void ConnectionWatcherTask(CancellationToken cancellationToken)
        //{
        //    // This task takes care of automatically reconnecting the interface
        //    // when the connection is drop or if an I/O error occurs
        //    while (!cancellationToken.IsCancellationRequested)
        //    {
        //        if (gotReadWriteError)
        //        {
        //            try
        //            {
        //                Close();
        //                // wait 1 sec before reconnecting
        //                Thread.Sleep(1000);
        //                if (!cancellationToken.IsCancellationRequested)
        //                {
        //                    try
        //                    {
        //                        Open();
        //                    }
        //                    catch (Exception e)
        //                    {
        //                        Console.WriteLine(e);
        //                    }
        //                }
        //            }
        //            catch (Exception e)
        //            {
        //                Console.WriteLine(e);
        //            }
        //        }
        //        if (!cancellationToken.IsCancellationRequested)
        //            Thread.Sleep(1000);
        //    }
        //}

        //private async Task ConnectionWatcherTask(CancellationToken cancellationToken)
        //{
        //    // This task takes care of automatically reconnecting the interface
        //    // when the connection is drop or if an I/O error occurs
        //    while (!cancellationToken.IsCancellationRequested)
        //    {
        //        if (_gotReadWriteError)
        //        {
        //            Connect();
        //        }
        //        await Task.Delay(1000, cancellationToken);
        //    }
        //}

        #endregion

        #region Events Raising

        /// <summary>
        /// Raises the connected state changed event.
        /// </summary>
        /// <param name="args">Arguments.</param>
        protected virtual void OnConnectionStatusChanged(ConnectionStatusChangedEventArgs args)
        {
            ConnectionStatusChanged?.Invoke(this, args);
        }