多线程/进度条应用(progressbar)
使用Control Sets 下的 ProgressBar - Responsive Loop控件

ProcessBar 或者 CancelBar 都可以被设置为 invisible
代码如下(分享自PowerShell群):
$OnLoadFormEvent = {
#TODO: Initialize Form Controls here
}
$buttonCancelProcess_Click = {
$script:CancelLoop = $true
}
$buttonStartProcess_Click = {
#Init CancelLoop
$script:CancelLoop = $false
$buttonCancelProcess.Enabled = $true
#Disable the button so we don't trigger it again
$this.Enabled = $false
#Reset the Progress Bar
$progressbar1.Value = 0
for ($i = 0; $i -lt $progressbar1.Maximum; $i++)
{
#----------------------------------------
#Place custom script here
$richtextbox1.AppendText($i.ToString() + "`r`n")
sleep -Seconds 1
#----------------------------------------
#process the pending message
[System.Windows.Forms.Application]::DoEvents()
if ($script:CancelLoop -eq $true)
{
#Clear the progress bar
$progressbar1.Value = 0
#Exit the loop
break;
}
#Step the progress bar
$progressbar1.PerformStep()
}
#Enable the button so we can click it again
$this.Enabled = $true
$buttonCancelProcess.Enabled = $false
}
$richtextbox1_TextChanged={
#TODO: Place custom script here
$richtextbox1.ScrollToCaret()
}
$buttonRunProcess_Click={
$buttonRunProcess.Enabled = $false
#TODO: Set the process path there
Add-ProcessTracker -FilePath "$env:windir/System32/notepad.exe" `
-CompletedScript {
$buttonRunProcess.Enabled = $true
$buttonRunProcess.ImageIndex = -1
}`
-UpdateScript {
#Animate the Button
if($buttonRunProcess.ImageList -ne $null)
{
if($buttonRunProcess.ImageIndex -lt $buttonRunProcess.ImageList.Images.Count - 1)
{
$buttonRunProcess.ImageIndex += 1
}
else
{
$buttonRunProcess.ImageIndex = 0
}
}
}
}
进度条显示代码(同样是使用Control Sets 下的 ProgressBar - Responsive Loop控件),代码如下:
for ($i = 0; $i -lt 100; $i++)
{
$progressbar1.Minimum = 0
$progressbar1.Maximum = 99
$progressbar1.Value = $i
#Start-Sleep 1
}
多线程/进度条应用(progressbar)的更多相关文章
- android多线程进度条
多线程实现更新android进度条. 实例教程,详细信息我已经注释 android多线程进度条 01package com.shougao.hello; 02 03import android ...
- 进度条(Progressbar)
进度条(Progressbar) 提供如下一些样式改变进度条的外观 @android:style/Widget.ProgressBar.Horizontal(水平进度条) @android:style ...
- 一个利用 Parallel.For 并行处理任务,带有进度条(ProgressBar)的 WinForm 实例(下)
接着上一篇:一个利用 Parallel.For 并行处理任务,带有进度条(ProgressBar)的 WinForm 实例(上) 直接贴代码了: using System; using System. ...
- Android 基于帧布局实现一个进度条 FrameLayout+ProgressBar
在FrameLayout中添加一个ProgressBar居中 <ProgressBar android:layout_gravity="center" android:id= ...
- android之进度条组件ProgressBar
首先是main.xml文件 代码如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android& ...
- 进度条(ProgressBar)的功能与用法
进度条也是UI界面中一种非常实用的组件,通常用于向用户显示某个耗时操作完成的的百分比.进度条可以动态的显示进度,因此避免长时间的执行某个耗时的操作,让用户感觉程序失去了响应,从而更好的提高用户界面的友 ...
- C#控件之:进度条(ProgressBar)
一.重绘进度条 public class CustomProgressBar:ProgressBar { public CustomProgressBar() { this.SetStyle(Cont ...
- [置顶] 自定义的解压进度条 关于ProgressBar的使用
整体布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...
- C#多线程进度条
public class ZyjProgressBar : System.Windows.Forms.ProgressBar { //用于跨线程访问控件的委托 private delegate voi ...
随机推荐
- Java [Leetcode 232]Implement Queue using Stacks
题目描述: Implement the following operations of a queue using stacks. push(x) -- Push element x to the b ...
- HDU 1041 Computer Transformation
这道题目的意思是:一开始有一个数字 1 ,在接下来的时间中,计算机会按照如下规则进行扩展: 0 –> 1 0 1 –> 0 1 ...
- 在linux设置环境变量
1.直接用export命令:#export PATH=$PATH:/opt/au1200_rm/build_tools/bin查看是否已经设好,可用命令export查看: [root@localhos ...
- Oracle EM 不能访问
zwt2001267 原文 Oracle EM 不能访问 1. cmd控制启动EM: C:\Users\Administrator>emctl start dbconsoleEnvironmen ...
- Delphi TRichEdit加载word内容
procedure TForm1.btn6Click(Sender: TObject);var WordApp: Variant; //声明一个word对象beginWordApp := Create ...
- 在Ubuntu下卸载Apache
卸载Apache 转自:http://blog.csdn.net/chmo2011/article/details/7026384 1. 删除apache 代码: $ sudo apt-get --p ...
- HDU 2227-Find the nondecreasing subsequences(dp+BIT优化)
题意: 给你一个序列a[],求它的不降子序列的个数 分析: dp[i]表示以i结尾不降子序列的个数,dp[i]=sum(dp[j])+1(j<i&&a[j]<=a[i]); ...
- SQL经典笔试题之一
本题用到下面三个关系表: CARD 借书卡. CNO 卡号,NAME 姓名,CLASS 班级 BOOKS 图书. BNO 书号,BNAME 书名,AUTHOR 作者,PRIC ...
- hadoop1.2.1三种模式配置
1.本地模式 本地模式的安装 将hadoop 安装包解压后不用任何配置就是默认的本地模式 此时 core-site.xml ,hdfs-site.xml , marped.site.xml 三个配置文 ...
- Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...