IoTOnboardingService.OnboardingService.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
        public async void Start()
        {
            try
            {
                _iconFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///IoTOnboardingService/icon72x72.png"));

                var connectionProfiles = NetworkInformation.GetConnectionProfiles();
                foreach (var profile in connectionProfiles)
                {
                    if (profile.IsWlanConnectionProfile)
                    {
                        lock (_stateLock)
                        {
                            _state = OnboardingState.ConfiguredValidated;
                        }
                        break;
                    }
                }

                if (_softAccessPoint == null)
                {
                    _softAccessPoint = new OnboardingAccessPoint(string.Format(_resourceLoader.GetString("SoftApSsidTemplate"), _onboardingInstanceId), _resourceLoader.GetString("SoftApPassword"));
                }

                if (_busAttachment == null)
                {
                    _busAttachment = new AllJoynBusAttachment();
                    _busAttachment.AboutData.DefaultDescription = string.Format(_resourceLoader.GetString("DefaultDescriptionTemplate"), _onboardingInstanceId);
                    _busAttachment.AboutData.DefaultManufacturer = _resourceLoader.GetString("DefaultManufacturer");
                    _busAttachment.AboutData.ModelNumber = _resourceLoader.GetString("ModelNumber");

                    _onboardingProducer = new OnboardingProducer(_busAttachment);
                    _onboardingProducer.Service = this;

                    _iconProducer = new IconProducer(_busAttachment);
                    _iconProducer.Service = this;
                }

                if (_deviceWatcher == null)
                {
                    var accessStatus = await WiFiAdapter.RequestAccessAsync();
                    if (accessStatus == WiFiAccessStatus.Allowed)
                    {
                        _deviceWatcher = DeviceInformation.CreateWatcher(WiFiAdapter.GetDeviceSelector());
                        _deviceWatcher.Added += this.HandleAdapterAdded;
                        _deviceWatcher.Removed += this.HandleAdapterRemoved;

                        _deviceWatcher.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }