private async Task LetsSingExecute() { try { await ExecuteBusyAction(async() => { if (string.IsNullOrWhiteSpace(UserName)) { await PageDialogService.DisplayAlertAsync("Really?", "Maybe you forgot something!", "Ok"); return; } if (CurentUser == null) { await UserService.Add(UserName); } await SignalRService.Connect(); await NavigationService.NavigateAsync("../Home"); }); } catch (System.Exception ex) { Debug.WriteLine(ex); } }
public async Task ConnectAsync() { await _signalRService.Connect(); _signalRService.OnMessageReceive((name, message) => { var messageObj = new SignalRMessage { Name = name, Message = message }; Messages.Add(messageObj); }); }
public async void Run(IBackgroundTaskInstance taskInstance) { _Deferral = taskInstance.GetDeferral(); var signalServer = new SignalRService(); var lightService = new LightsService(); // var chartService = new ChartService(lightService); var schedulePlan = new SchedulePlanService(); var mqttService = new MQTTServer(); await signalServer.Connect(lightService, mqttService, schedulePlan); await mqttService.ServerRun(signalServer); // var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); // var taskName = "test"; // if (backgroundAccessStatus == AlwaysAllowed) // { // foreach (var task in BackgroundTaskRegistration.AllTasks) // { // if (task.Value.Name == taskName) // { // return; // } // } // } // // BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder(); // taskBuilder.Name = taskName; // taskBuilder.TaskEntryPoint = // var status = await BackgroundExecutionManager.RequestAccessAsync(); // var taskName = "test"; // if (BackgroundTaskRegistration.AllTasks.All(x => x.Value.Name != taskName)) // { // BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); // builder.Name = taskName; // builder.TaskEntryPoint = typeof(LightHBackgroundIotHttpService.TileUpdateTask).FullName; // builder.SetTrigger(new TimeTrigger(16,false)); // // if (status != BackgroundAccessStatus.Denied) // { // builder.Register(); // } // } // chartService.SmartSwitchingLights(true, lightService); // await ThreadPool.RunAsync(workItem => // { // webserver.Start(); // // }); }