private void appBar_OnSave(object sender, EventArgs e) { authenticated = false; var periodicTask = new PeriodicTask("PeriodicTaskDemo") { Description = "Are presenting a periodic task" }; //MessageBox.Show(listPicker.SelectedItem.ToString()); if (usertxt.Text == "" || Password1.Password == "") { MessageBox.Show("Username or Password Missing"); return; } if (user.SelectedItem.ToString() == "Customer") { try { ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.AuthenticateCustomerCompleted += new EventHandler<ServiceReference1.AuthenticateCustomerCompletedEventArgs>(AuthenticateReturnFunction); clientfortesting.AuthenticateCustomerAsync(usertxt.Text.ToString(), Password1.Password.ToString()); // Scheduled Agent ScheduledActionService.Add(periodicTask); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(3)); //MessageBox.Show("Background agent started"); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(60)); } catch (Exception ex) { //MessageBox.Show(ex.Message.ToString()); } //NavigationService.Navigate(new Uri("/MainMenu.xaml", UriKind.Relative)); } else if (user.SelectedItem.ToString() == "Driver") { try { ServiceReference1.ServiceClient clientfortesting = new ServiceReference1.ServiceClient(); clientfortesting.AuthenticateDriverCompleted += new EventHandler<ServiceReference1.AuthenticateDriverCompletedEventArgs>(AuthenticateDriverReturnFunction); clientfortesting.AuthenticateDriverAsync(usertxt.Text.ToString(), Password1.Password.ToString()); // Scheduled Agent ScheduledActionService.Add(periodicTask); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(3)); //MessageBox.Show("Background agent started"); ScheduledActionService.LaunchForTest("PeriodicTaskDemo", TimeSpan.FromSeconds(60)); } catch (Exception ex) { //MessageBox.Show(ex.Message.ToString()); } } }