Esempio n. 1
0
 private void OnDiscoveryFinished(object sender, DiscoveryFinishedEventArgs e)
 {
     if (e.RemoteMinProtocolTooHigh)
     {
         SoftwareUpdateRequired?.Invoke(this, new EventArgs());
     }
     NotifyChange(new String[] { "IsDiscovering", "IsConnectingOrDiscovering" });
 }
Esempio n. 2
0
        /// <summary>
        /// Notifies the given discovery listeners that the discovery process has finished.
        /// </summary>
        /// <param name="error">The error message, or <c>null</c> if the process finished
        /// successfully.</param>
        private void NotifyDiscoveryFinished(string error)
        {
            if (error != null && error.Length > 0)
            {
                logger.ErrorFormat("{0}Finished discovery: {1}", xbeeDevice, error);
            }
            else
            {
                logger.DebugFormat("{0}Finished discovery.", xbeeDevice);
            }

            if (DiscoveryFinished == null)
            {
                return;
            }

            try
            {
                lock (DiscoveryFinished)
                {
                    var handler = DiscoveryFinished;
                    if (handler != null)
                    {
                        var args = new DiscoveryFinishedEventArgs(error);

                        handler.GetInvocationList().AsParallel().ForAll((action) =>
                        {
                            action.DynamicInvoke(this, args);
                        });
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
            }
        }