public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); taskInstance.Canceled += OnTaskCanceled; _source = new CancellationTokenSource(); _listener = new DeviceListener( brick: new Brick(new CommunicationFactory(), new FileProvider()), notify: NotifyMethodAsync ); await ThreadPool.RunAsync(async _ => { await _listener.ConnectAsync(_source.Token); await _listener.InitializeAsync(); }); }
private void ConnectClick(object sender, RoutedEventArgs e) { Task.Run(async() => await _listener.ConnectAsync(_tokenSource.Token)); }