protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args) { base.OnBackgroundActivated(args); if (args.TaskInstance.TriggerDetails is AppServiceTriggerDetails details) { appServiceDeferral = args.TaskInstance.GetDeferral(); var ns = ReactPropertyBagHelper.GetNamespace("RegistryChannel"); var name = ReactPropertyBagHelper.GetName(ns, "AppServiceConnection"); InstanceSettings.Properties.Set(name, details.AppServiceConnection); } }
public async Task <string> GetRegistryKey(string key) { var ns = ReactPropertyBagHelper.GetNamespace("RegistryChannel"); var name = ReactPropertyBagHelper.GetName(ns, "AppServiceConnection"); var content = _reactContext.Handle.Properties.Get(name); var _connection = content as AppServiceConnection; ValueSet valueSet = new ValueSet { { "RegistryKeyName", key } }; var result = await _connection.SendMessageAsync(valueSet); string message = result.Message["RegistryKeyValue"].ToString(); return(message); }
public void Initialize(ReactContext reactContext) { Debug.WriteLine($"C# Properties.Prop1: {reactContext.Handle.Properties.Get(ReactPropertyBagHelper.GetName(null, "Prop1"))}"); Debug.WriteLine($"C# Properties.Prop2: {reactContext.Handle.Properties.Get(ReactPropertyBagHelper.GetName(null, "Prop2"))}"); var cppTimerNotification = ReactPropertyBagHelper.GetName(ReactPropertyBagHelper.GetNamespace("SampleModuleCppImpl"), "TimerNotification"); var csTimerNotification = ReactPropertyBagHelper.GetName(ReactPropertyBagHelper.GetNamespace("SampleModuleCS"), "TimerNotification"); reactContext.Handle.Notifications.Subscribe(cppTimerNotification, null, (object sender, IReactNotificationArgs args) => Debug.WriteLine($"C# module, C++ timer:: {args.Data}")); _timer = ThreadPoolTimer.CreatePeriodicTimer(new TimerElapsedHandler((timer) => { reactContext.Handle.Notifications.SendNotification(csTimerNotification, null, _timerCount); TimedEvent?.Invoke(++_timerCount); if (_timerCount == 5) { _timer?.Cancel(); } }), TimeSpan.FromMilliseconds(TimedEventIntervalMS)); }