string CheckChromeStarted() { string result = string.Empty; var response = BotHttpClient.TaskHttpGetToChrome("hi").Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { isChromeTaskDone = true; var hello = response.Content.ReadAsStringAsync().Result; //Console.WriteLine(hello); BotHttpClient.WriteChromeResponse(hello); result = hello; } return(result); }
public async Task <string> WaitUntilChromeIsRunnung(int frequency = 100, int timeout = 45000) { string result = string.Empty; isChromeTaskDone = false; var waitTask = Task.Run(async() => { while (!isChromeTaskDone) { var response = await BotHttpClient.TaskHttpGetToChrome("hi"); if (response.StatusCode == System.Net.HttpStatusCode.OK) { isChromeTaskDone = true; var hello = response.Content.ReadAsStringAsync().Result; //Console.WriteLine(hello); BotHttpClient.WriteChromeResponse(hello); result = hello; } if (GlobalDef.CurrentDesigner != null && GlobalDef.CurrentDesigner.IsRunningWF == false) { var respond = "Cancelled Run WF."; BotHttpClient.WriteChromeResponse(respond); result = respond; isChromeTaskDone = true; } await Task.Delay(frequency); } }); if (waitTask != await Task.WhenAny(waitTask, Task.Delay(timeout))) { // throw new TimeoutException(); result = "WaitUntilChromeIsRunnung TimeoutException"; LogApplication.Agent.LogError(result); } return(result); }