Unreliable Expect

Nov 7, 2014 at 5:13 PM
Edited Nov 8, 2014 at 4:30 AM
Dear Developers,

I have noticed that "expect" method does not always work as expected :), sometimes it just skips expected text and execution blocks

I am trying to do my own expect handler in Shell_DataReceived event
in DotNet v2, please look at the source code at:
http://pastebin.com/vH9uCWNi

I am trying to use async constructs like BeginExpect

Please let me know, how can I forcibly end such BeginExpect after it is being waited by
AR.AsyncWaitHandle.WaitOne()

see:
AR = Shell.BeginExpect(New Renci.SshNet.ExpectAction(StopOnText, AddressOf F1))

Thanks for your help
Nov 7, 2014 at 5:15 PM
Edited Nov 7, 2014 at 5:42 PM
I need somehow to break waiting in the fragment:
         If InStr(S, StopOnText, CompareMethod.Text) > 0 Then


                HOW_TO_BREAK_WaitOne_HERE ???


        End If

Sorry, I am not good in multithreaded and async programming, it seems I just need to break WaitOne somehow from another place, is it possible?
Nov 7, 2014 at 5:20 PM
Edited Nov 7, 2014 at 5:43 PM
I fixed it by :
        If InStr(S, StopOnText, CompareMethod.Text) > 0 Then


                   System.Threading.WaitHandle.SignalAndWait(AR.AsyncWaitHandle, AR.AsyncWaitHandle, 1, False)


        End If
May be another signaling method can be used without second wait?

Btw, SignalAndWait is not always reached, IMHO it indicates unreliability of expect