public ResolveBeaconActionsAsync ( List |
||
beacons | List |
|
outOfRangeDb | int | |
리턴 | System.Threading.Tasks.Task |
// [Timeout(10000)] public async Task ResolveBackgroundEvent() { logger.Debug("ResolveBackgroundEvent - Start"); LayoutManager layoutManager = (LayoutManager) ServiceManager.LayoutManager; await layoutManager.VerifyLayoutAsync(true); BeaconAction orgAction = layoutManager.Layout.ResolvedActions.FirstOrDefault(ra => ra.BeaconAction.Uuid == "9ded63644e424d758b0218f7c70f2473").BeaconAction; List<Beacon> list = new List<Beacon>() {new Beacon() {Id1 = "7367672374000000ffff0000ffff0004", Id2 = 39178, Id3 = 30929}}; BackgroundEngine engine = new BackgroundEngine(); TaskCompletionSource<BeaconAction> action = new TaskCompletionSource<BeaconAction>(); engine.BeaconActionResolved += (sender, args) => { action.SetResult(args); }; await engine.InitializeAsync(); await engine.ResolveBeaconActionsAsync(list, OUT_OF_RANGE_DB); BeaconAction result = await action.Task; Assert.AreEqual(orgAction, result, "action not found"); logger.Debug("ResolveBackgroundEvent - End"); }
public async void Run(IBackgroundTaskInstance taskInstance) { Deferral = taskInstance.GetDeferral(); await BackgroundEngine.InitializeAsync(); var triggerDetails = taskInstance.TriggerDetails as BluetoothLEAdvertisementWatcherTriggerDetails; if (triggerDetails != null) { if (triggerDetails.Error == BluetoothError.RadioNotAvailable) { AdvertisementError?.Invoke(this, triggerDetails.Error); } else { int outOfRangeDb = triggerDetails.SignalStrengthFilter.OutOfRangeThresholdInDBm.HasValue ? triggerDetails.SignalStrengthFilter.OutOfRangeThresholdInDBm.Value : 0; await BackgroundEngine.ResolveBeaconActionsAsync(TriggerDetailsToBeacons(triggerDetails), outOfRangeDb); } } //setting any value to Progress will fire Progress event with UI app taskInstance.Progress = 1; }
public async Task ResolveMultipleAction() { logger.Debug("ResolveMultipleAction - Start"); LayoutManager layoutManager = (LayoutManager) ServiceManager.LayoutManager; await layoutManager.VerifyLayoutAsync(true); BackgroundEngine engine = new BackgroundEngine(); IList<BeaconAction> actions = new List<BeaconAction>(); engine.BeaconActionResolved += (sender, args) => { actions.Add(args); }; List<Beacon> list = new List<Beacon>() {new Beacon() {Id1 = "7367672374000000ffff0000ffff0003", Id2 = 48869, Id3 = 21321}}; await engine.InitializeAsync(); await engine.ResolveBeaconActionsAsync(list, OUT_OF_RANGE_DB); Assert.AreEqual(4, actions.Count, "Not 4 action found"); logger.Debug("ResolveMultipleAction - End"); }