private void Button_Click(object sender, RoutedEventArgs e) { if (isFinding) { return; } findButton.Content = "正在查找..."; findButton.IsEnabled = false; isFinding = true; LogLabel.Text = "正在查找...\n"; killAllFindThread(); resetClinet(); string localIp = GetLocalIP(); Console.WriteLine(localIp); string ipPre = localIp.Substring(0, localIp.LastIndexOf('.') + 1); new Thread(() => { for (int i = 0; i <= 255; i++) { string para = ipPre + i.ToString(); Thread t1 = new Thread(new ParameterizedThreadStart(findConnect)); t1.IsBackground = true; threadList.Add(t1); t1.Start(para); t1.Priority = ThreadPriority.BelowNormal; Thread.Sleep(50); //findConnect(para); } }).Start(); listView.ItemsSource = androidClientList; Console.WriteLine("!!!!*******************$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); new Thread(() => { TimeSpan ts = new TimeSpan(0, 0, 1); for (int i = 23; i > 0; i--) { Thread.Sleep(ts); } UpdateFindButton updateFindButton = new UpdateFindButton(UpdateFindButtonUI); this.Dispatcher.Invoke(updateFindButton, true); }).Start(); installButton.IsEnabled = true; uninstallButton.IsEnabled = true; customButton.IsEnabled = true; LogViewer.ScrollToEnd(); }
private void AppendLog(string str, bool newline = true) { if (newline) { str += "\r"; } Dispatcher.Invoke(new Action(() => { LogViewer.AppendText(str); LogViewer.ScrollToEnd(); })); }
private void UpdateLogLabelUI(string str) { LogLabel.Text = LogLabel.Text + str; LogViewer.ScrollToEnd(); }