多线程/进度条应用(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 ...
随机推荐
- 【WEB小工具】jQuery函数
jQuery-API帮助文档:Click here jQuery简介 jQuery是JavaScript框架,jQuery也是JavaScript代码.使用jQuery要比直接使用JavaScript ...
- ioctl()获取本地网卡设备信息
获得eth0接口所有信息: #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #inclu ...
- hdu 2473 Junk-Mail Filter(并查集_虚节点)2008 Asia Regional Hangzhou
感觉有些难的题,刚开始就想到了设立虚节点,但是实现总是出错,因为每次设立了虚节点之后,无法将原节点和虚节点分开,导致虚节点根本无意义. 以上纯属废话,可以忽略…… 题意—— 给定n个点(0, 1, 2 ...
- CGAffineTransformScale
[UIViewbeginAnimations:nilcontext:nil]; [UIViewsetAnimationDuration:0.5]; _imgView.transform = CGAff ...
- 新版本ubuntu13.10软件安装
问题1:如何解决ubunt13.04不能和主机共享文件的问题 . 安装VMware Tools 网上有很多的资料,这里没有给出. . 设置共享文件夹目录 ) 在VMware虚拟机窗口,选择VM-> ...
- NGUI的UIProgressBar使用裁剪方式而不是压缩方式的方法
UIProgressBar默认的方式是压缩图片,而如果我们需要裁减图片,只需要将UIProgressBar的Foreground的UISprite的Type改为Filled就行了. 好几个“的”... ...
- webstrom11 激活,webstorm 2016.1激活
http://15.idea.lanyus.com/ webstorm11注册激活,你值得拥有 webstorm 2016.1 最新激活方式:http://blog.lanyus.com/archi ...
- HDU-4737 A Bit Fun 维护
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4737 题意:给一个数列a0, a1 ... , an-1,令 f(i, j) = ai|ai+1|ai ...
- Socket.io:有点意思
个人网站 欢迎品尝 edwardesire.com 下面页面就是使用Socket.io制作的口袋妖怪游戏(默认小屏下已隐藏,请切换到大分辨率查看).左边是游戏画面,右边是按键表和聊天室.画面达到红蓝版 ...
- linux 命令 之chomd
chmod用于改变文件或目录的访问权限.用户用它控制文件或目录的访问权限.该命令有两种用法.一种是包含字母和操作符表达式的文字设定法:另一种是包含数字的数字设定法. 1. 文字设定法 语法:chmo ...