我有一个在我的页面上运行47次的循环.在每个循环的过程中,任何错误消息都输入到err []并打印出来.我试图在每次迭代后清空数组,我遇到了一些麻烦.
每次迭代可能有4或5个错误消息,有时没有.除了运行另一个foreach循环并取消设置每个值之外,是否有更简单的方法在每次迭代后重置整个数组?一种清除所有内容并重置索引而不实际删除数组本身的方法?
我有一个计时器,除其他外,检查屏幕上的5个点是否有颜色变化.我的程序监控电话系统应用程序并检查是否有来自5个按钮中的任何一个的新来电.我根据我发布的另一个问题使用以下代码. 在Visual Basic中监视屏幕的某个颜色区域
Private Function CheckforCall()
Try
Dim queue1 As Integer = GetPixel(GetDC(0), 40, 573)
Dim queue2 As Integer = GetPixel(GetDC(0), 140, 573)
Dim queue3 As Integer = GetPixel(GetDC(0), 240, 573)
Dim queue4 As Integer = GetPixel(GetDC(0), 340, 573)
Dim queue5 As Integer = GetPixel(GetDC(0), 440, 573)
ReleaseDC(0)
<code snipped - Checks to see if the pixel color matches and
returns true or false>
Catch ex As Exception
Return False
End Try
End Function
Run Code Online (Sandbox Code Playgroud)
使用此代码,GDI对象可以非常快速地在短时间内突然出现,抛出OutOfMemory异常.我假设我没有正确释放DC,但我似乎无法找到任何其他方法来做到这一点.