Compare-Object -ReferenceObject $MaintenanceWindows -DifferenceObject $ScomAlerts -Property Computername -IncludeEqual -PassThru |
Where-Object { $_.SideIndicator -match '==|=>' } |
Select-Object ComputerName, @{n="Collection Name";e={ if($_."Collection Name"){ $_."Collection Name" } else { "Not Found!" } }}
Computername Collection Name
------------ ---------------
Server2 NA - All DA Servers - Patching - Cert - Thu 2:00
Server3 Not Found!
这是我在Windows窗体应用程序中使用的代码部分 我希望它输入值并显示它上升但是它只是跳到最后并放置最后一个输出而不是计数。 有些人说使用计时器,但我无法让他们上班。 有什么想法吗?
答案 0 :(得分:0)
您正在使用循环锁定UI线程,以便在完成其工作之前不会更新控件。当循环完成并且UI刷新时,您最终只能看到最终值。
请改为使用Timer
控件。您可以告诉它定期举起一个事件,它将允许您的UI正确更新。
将Timer
添加到Form
,然后将以下代码插入构造函数中以进行尝试。目前,它每1毫秒更新一次你的元素(实际上,它不会那么快)。
int i = 0;
int j = 10;
timer1.Interval = 1;
timer1.Tick += (s, e) =>
{
string y = i.ToString();
webBrowser1.Document.GetElementById("lst-ib").SetAttribute("value", y);
i++;
j++;
if (j > 1000)
timer1.Stop();
};
timer1.Start();