void WaitWhileLoading() { while (!IsFree && CheckIfWebViewIsLoading()) { SynchronizationHelper.Pause(3); } }
void Block() { while (isWorkingNow) { SynchronizationHelper.Pause(10); } isWorkingNow = true; }
public void FinishConversation(bool isCompleted) { this.isCompleted = isCompleted; while (!IsConversationFinished) { SynchronizationHelper.Pause(200); } }
void FindCompanion(int countOfTryes) { if (countOfTryes <= 0) { throw new Exception("Out of tryes to find companion."); } chatMessagesList = new List <ChatMessage>(); /*companionSearchSettings != null && previousCompanionSearchSettings == companionSearchSettings &&*/ if (RestartConversationIfCan()) { return; } CustomBrowser.LoadPage(chatStartUrl); InitJs(); try { GetWithUpdate_IsStillTalking(); } catch { throw new Exception("Page load exception!"); } //SynchronizationHelper.Pause(500); //string scriptToSetSettings = JsFor_SetSearchSettings(companionSearchSettings); //CustomBrowser.ExJs(scriptToSetSettings); SynchronizationHelper.Pause(200); CustomBrowser.ExJs(JsFor_ClickSearchButtononStartUrl); InitJs(); //SynchronizationHelper.WaitFor( // GetWithUpdate_IsSearchingCompanion, 20000); SynchronizationHelper.WaitFor( () => { if (GetWithUpdate_IsStillTalking()) { return(true); } SynchronizationHelper.Pause(250); return(false); }, 10000); //previousCompanionSearchSettings = companionSearchSettings; if (!GetWithUpdate_IsStillTalking()) { FindCompanion(countOfTryes - 1); } CheckCaptchaAndWait(); }
/// <summary> /// Не используется и, возможно, никогда не будет. /// </summary> public void SimulateWriting(int timeMS) { int waiInOneLoop = 200; while (timeMS > 0) { CustomBrowser.ExJs(JsFor_SimulateWriting); SynchronizationHelper.Pause(waiInOneLoop); timeMS -= waiInOneLoop; } CustomBrowser.ExJs(JsFor_ClearTextArea); SynchronizationHelper.Pause(50); }
public void CheckCaptchaAndWait() { int loopNum = 0; while (!IsFree && GetWithUpdate_CheckCaptcha() && loopNum++ < 40) { TrayHelper.ShowTextInTray("Captcha", "You must enter captcha in chatvdvoem window!"); SynchronizationHelper.Pause(7000); } if (loopNum >= 40) { throw new Exception("Captcha wasn`t entered!"); } }
/// <summary> /// ≈сли хотите добавл¤ть новые методы по работе с WebView - добавл¤йте их через Їтот метод. /// </summary> void InvokeToWebViewThread(Action method) { if (IsFree) { return; } var actAndBool = new ActionAndBool(method); actionToInvoke.Add(actAndBool); while (!IsFree && !actAndBool.IsExecuted) { SynchronizationHelper.Pause(10); } }
/// <summary> /// Return true if conversation restarted. /// </summary> /// <returns></returns> bool RestartConversationIfCan() { bool res = false; try { CustomBrowser.ExJs(JsFor_ClickSearchNewCompanionButton); SynchronizationHelper.Pause(200); SynchronizationHelper.WaitFor( GetWithUpdate_IsSearchingCompanion, 20000); SynchronizationHelper.WaitFor( () => { return(!GetWithUpdate_IsStillTalking()); }, 15000); res = GetWithUpdate_IsStillTalking(); } catch { } return(res); }
public void DoEvents() { ThrowStopExceptionIfNeed(); SynchronizationHelper.Pause(100); }
public void FinishConversation() { InitJs(); CustomBrowser.ExJs(JsFor_FinishConversation); SynchronizationHelper.Pause(300); }