public async void UpdateContent() { var old_select = this.SelectedItem; Items.Clear(); using (BlockSyncContext.Enter()) foreach (var item in await client.GetExploreQueueName()) { Items.Add(new ComboBoxItem(item)); } if (old_select != null) { block_signal = true; foreach (var item in Items) { if (((ComboBoxItem)item).type == ((ComboBoxItem)old_select).type) { if (((ComboBoxItem)item).id == ((ComboBoxItem)old_select).id) { this.SelectedItem = item; block_signal = false; return; } } } block_signal = false; //即使选中的队列已不存在,也没有必要清空 } }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (BlockSyncContext.Enter()) Application.Run(new MainWindow()); } catch (Exception ex) { MessageBox.Show(string.Format("捕获到未处理异常:{0}\r\n异常信息:{1}\r\n异常堆栈:{2}", ex.GetType(), ex.Message, ex.StackTrace)); } }
private void OnQueueComboBoxChanged(object sender, QueueChangeEventArgs e) { using (BlockSyncContext.Enter()) MainExplorer.SetList(pixiv_client.GetExploreQueue(e.type, e.name).Result); }