Example #1
0
        /// <summary>
        /// Handles the ConnectionStatus event.
        /// </summary>
        /// <param name="sender">The object which sent this event.</param>
        /// <param name="args">Event arguments.</param>
        private void DevicePortal_ConnectionStatus(
            DevicePortal sender,
            DeviceConnectionStatusEventArgs args)
        {
            if (args.Status == DeviceConnectionStatus.Connected)
            {
                // Connection successfully established.
                this.firstContact = true;
                this.devicePortal = sender;
                this.devicePortal.AppInstallStatus += DevicePortal_AppInstallStatus;
                this.devicePortal.ConnectionStatus -= DevicePortal_ConnectionStatus;

                if (this.connectOptions.DeployNameToDevice)
                {
                    Task.Run(
                        async() =>
                    {
                        if (await this.SetDeviceNameAsync(this.connectOptions.Name))
                        {
                            await this.RebootAsync();
                        }
                    });
                }
            }
            else if (args.Status == DeviceConnectionStatus.Failed)
            {
                // Connection failed.
                this.firstContact = false;
                this.devicePortal.ConnectionStatus -= DevicePortal_ConnectionStatus;

                throw new Exception(args.Message);
            }
        }
Example #2
0
        private void DevicePortalConnectionStatus(DevicePortal sender, DeviceConnectionStatusEventArgs args)
        {
            // This can get called back on random threads.  Marshal it back to the UI thread if needed

            if (MainThread.IsMainThread)
            {
                this.DeviceConnectionStatus = args.Status;
            }
            else
            {
                // Not clear if this is the right thing to do in the Xamarin world using TPL
                MainThread.BeginInvokeOnMainThread(() => { this.DevicePortalConnectionStatus(sender, args); });
            }
        }
        /// <summary>
        /// Handles the ConnectionStatus event.
        /// </summary>
        /// <param name="sender">The object which sent this event.</param>
        /// <param name="args">Event arguments.</param>
        private void DevicePortal_ConnectionStatus(
            DevicePortal sender,
            DeviceConnectionStatusEventArgs args)
        {
            if (args.Status == DeviceConnectionStatus.Connected)
            {
                // Connection successfully established.
                this.devicePortal = sender;
                this.devicePortal.AppInstallStatus += DevicePortal_AppInstallStatus;

                // Start the heartbeat.
                Task t = CheckHeartbeatAsync();
                t.Wait();

                this.devicePortal.ConnectionStatus -= DevicePortal_ConnectionStatus;
            }
            else if (args.Status == DeviceConnectionStatus.Failed)
            {
                this.devicePortal.ConnectionStatus -= DevicePortal_ConnectionStatus;

                // Connection failed.
                throw new Exception(args.Message);
            }
        }
Example #4
0
 private void DevicePortal_ConnectionStatus(DevicePortal sender, DeviceConnectionStatusEventArgs args)
 {
     IsConnected = args.Status == DeviceConnectionStatus.Connected;
     Message     = sender.ConnectionFailedDescription;
 }