private void LoginAsyncBegin() { DisplayLogingInfo(); var taskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); var task = Task <string> .Factory.StartNew(() => DokuFlexService.Login(_credentials)); task.ContinueWith(t => LoginAsyncEnd(t.Result), taskScheduler); task.ContinueWith(t => TaskAsyncExceptionHandle(t.Exception), new CancellationTokenSource().Token, TaskContinuationOptions.OnlyOnFaulted, taskScheduler); }
public static string GetTikect() { var ticket = String.Empty; var credentials = new Credentials(); credentials.UserName = ConfigurationManager.GetValue(Constants.LoginUserName); if (String.IsNullOrWhiteSpace(credentials.UserName)) { using (var form = new LoginView()) { if (form.ShowLoginDialog()) { ticket = form.Ticket; } } return(ticket); } credentials.SetEncryptedPassword(ConfigurationManager.GetValue(Constants.LoginPassword)); try { ticket = DokuFlexService.Login(credentials); } catch (Exception) { //silent exception } if (String.IsNullOrWhiteSpace(ticket)) { using (var form = new LoginView()) { if (form.ShowLoginDialog()) { ticket = form.Ticket; } } } return(ticket); }