1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 13:16:09 +03:00

学习使用多线程

This commit is contained in:
ProxySU 2020-03-10 13:44:00 +08:00
parent ad0b80fddd
commit e0c2b9efb0
2 changed files with 11 additions and 10 deletions

4
.gitignore vendored
View File

@ -13,13 +13,13 @@
# Build results # Build results
[Dd]ebug/ [Dd]ebug/
[Dd]ebugPublic/ [Dd]ebugPublic/
[Rr]elease/ # [Rr]elease/
[Rr]eleases/ [Rr]eleases/
x64/ x64/
x86/ x86/
build/ build/
bld/ bld/
[Bb]in/ # [Bb]in/
[Oo]bj/ [Oo]bj/
# Visual Studo 2015 cache/options directory # Visual Studo 2015 cache/options directory

View File

@ -33,6 +33,7 @@ namespace ProxySU
//System.Diagnostics.Process exitProgram = System.Diagnostics.Process.GetProcessById(System.Diagnostics.Process.GetCurrentProcess().Id); //System.Diagnostics.Process exitProgram = System.Diagnostics.Process.GetProcessById(System.Diagnostics.Process.GetCurrentProcess().Id);
private void Button_Login_Click(object sender, RoutedEventArgs e) private void Button_Login_Click(object sender, RoutedEventArgs e)
{ {
//主机指纹,暂未启用
//byte[] expectedFingerPrint = new byte[] { //byte[] expectedFingerPrint = new byte[] {
// 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31,
// 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b
@ -141,7 +142,7 @@ namespace ProxySU
using (var client = new SshClient(connectionInfo)) using (var client = new SshClient(connectionInfo))
{ {
#region #region ssh登录验证主机指纹代码块
// client.HostKeyReceived += (sender, e) => // client.HostKeyReceived += (sender, e) =>
// { // {
// if (expectedFingerPrint.Length == e.FingerPrint.Length) // if (expectedFingerPrint.Length == e.FingerPrint.Length)
@ -183,7 +184,7 @@ namespace ProxySU
} }
} }
catch (Exception ex1) catch (Exception ex1)//例外处理
{ {
//MessageBox.Show(ex1.Message); //MessageBox.Show(ex1.Message);
if (ex1.Message.Contains("连接尝试失败") == true) if (ex1.Message.Contains("连接尝试失败") == true)
@ -248,7 +249,7 @@ namespace ProxySU
TextBoxCertFilePath.Text = openFileDialog.FileName; TextBoxCertFilePath.Text = openFileDialog.FileName;
} }
} }
#region #region
private void RadioButtonNoProxy_Checked(object sender, RoutedEventArgs e) private void RadioButtonNoProxy_Checked(object sender, RoutedEventArgs e)
{ {
TextBlockProxyHost.IsEnabled = false; TextBlockProxyHost.IsEnabled = false;
@ -317,7 +318,7 @@ namespace ProxySU
PasswordBoxProxyPassword.IsEnabled = true; PasswordBoxProxyPassword.IsEnabled = true;
} }
#endregion #endregion
private void Begin(TextBlock textBlock) private void Begin(TextBlock textBlockName)
{ {
//int i = 100000000; //int i = 100000000;
//while (i > 0) //while (i > 0)
@ -327,12 +328,12 @@ namespace ProxySU
//Random random = new Random(); //Random random = new Random();
//String Num = random.Next(0, 100).ToString(); //String Num = random.Next(0, 100).ToString();
Action<TextBlock, String> updateAction = new Action<TextBlock, string>(UpdateTextBlockSetUpProcessing); Action<TextBlock, String> updateAction = new Action<TextBlock, string>(UpdateTextBlockSetUpProcessing);
TextBlockSetUpProcessing.Dispatcher.BeginInvoke(updateAction, textBlock, Num); TextBlockSetUpProcessing.Dispatcher.BeginInvoke(updateAction, textBlockName, Num);
} }
//更新UI代码 //更新UI显示内容
private void UpdateTextBlockSetUpProcessing(TextBlock textBlock, string text) private void UpdateTextBlockSetUpProcessing(TextBlock textBlockName, string text)
{ {
textBlock.Text = text; textBlockName.Text = text;
} }
} }
} }