void TeachnetCompleted(IAsyncOperation <string> async, AsyncStatus asyncStatus) { String st = async.GetResults(); StToInfo sttoinfo = new StToInfo(st); sttoinfo.SaveTodb(); using (var db = new ClassDb()) { if (db.Students.LongCount() != 0) { SaveToRam Str = new SaveToRam(); Str.Analysis(); } } pg.IsActive = false; }
private async void ContentDialog_SecondaryButtonClickAsync(ContentDialog sender, ContentDialogButtonClickEventArgs args) { bool isCheck = true; username = UserName.Text.ToString(); password = PassWord.Password.ToString(); pg.IsActive = true; Net.Teachnet teachnet = new Net.Teachnet(username, password); teachnet.initializeAsync(); // IAsyncOperation<string> iasync = teachnet.initializeAsync().Result; // iasync.Completed = TeachnetCompleted; int t; t = 0; while (teachnet.classinfo == null && t < 3) { await Task.Delay(2000); t++; } StToInfo saveToInfo = new StToInfo(teachnet.classinfo); saveToInfo.SaveTodb(); using (var db = new ClassDb()) { if (db.Students.LongCount() != 0) { SaveToRam Str = new SaveToRam(); Str.Analysis(); } } pg.IsActive = false; args.Cancel = isCheck; Frame f = Window.Current.Content as Frame; f.Navigate(typeof(Views.ShellView)); }