Terminal WaitForAsync ScriptEvent[]

0
This is probably something simple but I can't seem to find the answer. I am trying to use the WaitForAsync method with a TelnetTerminalControl. I am building my ScriptEvent array as per below and I get an error that it is not an array when I receive the callback. How do I build an array of ScriptEvent? Also, I am running in a headless mode, purely screen scraping, at what point should I consider all of a screen complete? Should I be polling for text or perhaps use tControl.Screen.GetRegionText? Thank you in advance! private void Test() { ScriptEvent[] searchText = new ScriptEvent[] { ScriptEvent.TextAtPosition("Test", 0, 0) }; tControl.WaitForAsync(searchText, asyncWaitCompleted); } // Error = {"Unable to cast object of type 'ComponentPro.Net.Terminal.ScriptEvent' to type 'ComponentPro.Net.Terminal.ScriptEvent[]'."} private void asyncWaitCompleted(Object obj, System.ComponentModel.AsyncCompletedEventArgs eventArgs) { updateScreenText(DumpScreen()); }
 
asked 4/22/2020 10:14:13 PM
add a comment

1 Answers

0
I ended up implementing my own AsyncWait using a thread and the blocking WaitForData() and calling CheckFor manually. The screen does not update completely on occasion so I added a loop that checked for DataReceived until it stops reeceiving. Even then, I still had to timeout higher up in the implementation and call SendAsync with an empty string, then call my AsyncWait to get the screen to update fully all of the time. ShellProcessingResult result = tControl.WaitForData(); if (scriptEvent == ScriptEvent.AnyText) { result = tControl.WaitForData(1000); } else { while (result == ShellProcessingResult.DataReceived) { result = tControl.WaitForData(100); } } if(result == ShellProcessingResult.Disconnected) { break; } //response = tControl.WaitFor(scriptEvent); if (scriptEvent != ScriptEvent.AnyText) { response = tControl.CheckFor(scriptEvent); if(response.Success) { bSuccess = true; } break; } else { bSuccess = true; break; }
 
answered 5/1/2020 10:15:47 PM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged ultimate terminal emulation or ask your own question.