使用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)的更多相关文章

  1. android多线程进度条

    多线程实现更新android进度条. 实例教程,详细信息我已经注释   android多线程进度条   01package com.shougao.hello; 02 03import android ...

  2. 进度条(Progressbar)

    进度条(Progressbar) 提供如下一些样式改变进度条的外观 @android:style/Widget.ProgressBar.Horizontal(水平进度条) @android:style ...

  3. 一个利用 Parallel.For 并行处理任务,带有进度条(ProgressBar)的 WinForm 实例(下)

    接着上一篇:一个利用 Parallel.For 并行处理任务,带有进度条(ProgressBar)的 WinForm 实例(上) 直接贴代码了: using System; using System. ...

  4. Android 基于帧布局实现一个进度条 FrameLayout+ProgressBar

    在FrameLayout中添加一个ProgressBar居中 <ProgressBar android:layout_gravity="center" android:id= ...

  5. android之进度条组件ProgressBar

    首先是main.xml文件 代码如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android& ...

  6. 进度条(ProgressBar)的功能与用法

    进度条也是UI界面中一种非常实用的组件,通常用于向用户显示某个耗时操作完成的的百分比.进度条可以动态的显示进度,因此避免长时间的执行某个耗时的操作,让用户感觉程序失去了响应,从而更好的提高用户界面的友 ...

  7. C#控件之:进度条(ProgressBar)

    一.重绘进度条 public class CustomProgressBar:ProgressBar { public CustomProgressBar() { this.SetStyle(Cont ...

  8. [置顶] 自定义的解压进度条 关于ProgressBar的使用

    整体布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...

  9. C#多线程进度条

    public class ZyjProgressBar : System.Windows.Forms.ProgressBar { //用于跨线程访问控件的委托 private delegate voi ...

随机推荐

  1. 使用源代码安装lnmp

    一.安装nginx前,安装pcre. # tar zxvf pcre-8.12.tar.gz# ./configure# make# make install 二.安装nginx # tar zxvf ...

  2. IOS UINavigationController 操作相关集合

    1.修改中间Title字体以及大小 [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dict ...

  3. http://blog.csdn.net/jbb0403/article/details/42102527

    http://blog.csdn.net/jbb0403/article/details/42102527

  4. Struts2动态调用DMI及错误解决方法

    在Strust2中action可以定义自己的方法,调用方法有两种方式,一种方式是struts.xml中指定method来表示需要用到的方法, 但是这种方法缺点在于如果你的Action中有很多方法则要多 ...

  5. Android-day02_广播

    1.什么是广播 貌似一个人大声喊一句话,别人听到了这就是广播 2.在android中广播有标准广播和有序广播 标准广播也就是发送一个广播,所有人都能同一时间接收到 有序广播则是有顺序的广播,发送的时候 ...

  6. 一些不错的英文歌曲MV,留个存档!

    Lambada [[http://www.yinyuetai.com/video/265213]]Trouble Is A Friend [[http://www.yinyuetai.com/vide ...

  7. Hard-Margin SVM(支持向量机)

    什么是Hard-Margin SVM?指的是这个向量机只适用于“数据完全可分(seperately)”的情况. (一)什么是支持向量机? 上述三条直线,选择哪一条比较好?直觉上来说,最右面的那条直线最 ...

  8. [LeetCode] Ugly Number II (A New Question Added Today)

    Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...

  9. lighttpd mod_status模块

    用过nginx的status可以查看服务器的状态,之后就想lighttpd有没有这样的模块呢 之后看下配置文件,真的有,然后就试下 第一步, "mod_auth" 把这个前面的#号 ...

  10. String比较

    String str1 = "abc"; String str2 = "abc"; String str3 = new String("abc&quo ...