1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 06:36:08 +03:00

学习使用多线程

This commit is contained in:
ProxySU 2020-03-10 07:57:08 +08:00
parent cb2adddafe
commit 2cc8134d46
2 changed files with 28 additions and 8 deletions

View File

@ -22,7 +22,9 @@
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30" ></RowDefinition>
<RowDefinition ></RowDefinition>
<RowDefinition ></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
@ -55,14 +57,13 @@
<TextBox x:Name="TextBoxProxyUserName" IsEnabled="False" Text="" Margin="5" Grid.Column="1" Grid.Row="6"></TextBox>
<PasswordBox x:Name="PasswordBoxProxyPassword" IsEnabled="False" Password="" Margin="5" Grid.Column="3" Grid.Row="6"></PasswordBox>
<StatusBar x:Name="StatusBarStatusMonitoring" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></StatusBar>
<!--<TextBlock x:Name="TextBlockSetUpProcessing" Text="等待安装布署" Grid.Column="1" Grid.Row="7" Grid.ColumnSpan="3"></TextBlock>
<ProgressBar x:Name="ProgressBarSetUpProcessing" Minimum="0" Maximum="100" Value="0" IsIndeterminate="False" Margin="7" Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="4"></ProgressBar>-->
<!--<TextBlock Text="代理类型:" Grid.Column="2" Grid.Row="3"></TextBlock>
<ComboBox x:Name="proxyType" Grid.Column="3" Grid.Row="3" Margin="5"></ComboBox>-->
<!--<StatusBar x:Name="StatusBarStatusMonitoring" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></StatusBar>-->
<TextBlock x:Name="TextBlockSetUpProcessing" Text="等待安装布署" Foreground="Blue" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></TextBlock>
<ProgressBar x:Name="ProgressBarSetUpProcessing" Minimum="0" Maximum="100" Value="0" IsIndeterminate="False" Margin="7" Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="4"></ProgressBar>
<Button x:Name="Button_Login" Content="布署安装" Grid.ColumnSpan="2" Margin="10" Grid.Column="0" Grid.Row="9" Click="Button_Login_Click"></Button>
<Button x:Name="Button_canel" Content="取消" Grid.ColumnSpan="2" Margin="10" Grid.Column="2" Grid.Row="9" Click="Button_canel_Click"></Button>
<Button x:Name="Button_Login" Content="布署安装" Grid.ColumnSpan="2" Margin="10" Grid.Column="0" Grid.Row="11" Click="Button_Login_Click"></Button>
<Button x:Name="Button_canel" Content="取消" Grid.ColumnSpan="2" Margin="10" Grid.Column="2" Grid.Row="11" Click="Button_canel_Click"></Button>
</Grid>
</Grid>
</Window>

View File

@ -13,6 +13,8 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Renci.SshNet;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace ProxySU
{
@ -315,5 +317,22 @@ namespace ProxySU
PasswordBoxProxyPassword.IsEnabled = true;
}
#endregion
private void Begin(TextBlock textBlock)
{
//int i = 100000000;
//while (i > 0)
//{
// i--;
//}
//Random random = new Random();
//String Num = random.Next(0, 100).ToString();
Action<TextBlock, String> updateAction = new Action<TextBlock, string>(UpdateTextBlockSetUpProcessing);
TextBlockSetUpProcessing.Dispatcher.BeginInvoke(updateAction, textBlock, Num);
}
//更新UI代码
private void UpdateTextBlockSetUpProcessing(TextBlock textBlock, string text)
{
textBlock.Text = text;
}
}
}