Hi Michael
Thanks for the info
I was wondering about this as we have a dialogue that sometimes appears which you have to click Yes which then you need to click Proceed. Both these buttons are being searched at the same time in the background but sometimes Proceed is not clicked. I'm a little wary that maybe the click is being dispatched too quickly after the first one found. I've chucked a Mutex and delay(it seemed the easiest way to do it) into my TryClick method which seems to work a treat.
Public Class ThreadData
Public _rxPath As String
Public _timeout As Integer
Public Sub New(ByVal rxPath As String, ByVal timeout As Integer)
_rxPath = rxPath
_timeout = timeout
End Sub
End Class
Public Sub TryClick(ByVal strRanorexPath As String, ByVal intTimeout As Integer, Optional ByVal singleThread As Boolean = False)
Dim data As New ThreadData(strRanorexPath, intTimeout)
If singleThread Then
TryClickMain(data)
Else
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf TryClickMain), data)
End If
End Sub
Private _Mutex As New Mutex
Private Sub TryClickMain(ByVal data As Object)
Dim _data As ThreadData = CType(data, ThreadData)
Dim Item As Ranorex.Unknown = Nothing
If Host.Local.TryFindSingle(_data._rxPath, _data._timeout, Item) = True Then
_Mutex.WaitOne()
Item.EnsureVisible()
Item.Click()
Thread.Sleep(1000)
_Mutex.ReleaseMutex()
End If
End Sub