I have an ActiveX control ("rumba" in my code) that connects to a mainframe. The code below works in WinForms, but I want to put the code in a class library project. With what do I replace Application.DoEvents()? I tried putting Thread.Sleep or just deleting the row but then rumba only starts to connect when the while cycle is done.
Here is my code:
public bool Connect(int timeOutInSeconds = 5)
{
DateTime limit = DateTime.Now.AddSeconds(timeOutInSeconds);
rumba.Connect();
while (DateTime.Now < limit)
{
string s = GetCurrentScreenAsText();
s = s.Replace("\0", null);
if (!string.IsNullOrWhiteSpace(s))
return true;
Application.DoEvents();
}
return false;
}