SEBWIN-488: Implemented pause before resetting or terminating browser in order to prevent application crashes.
This commit is contained in:
parent
7ad97b954c
commit
2364b57f40
1 changed files with 12 additions and 0 deletions
|
@ -10,6 +10,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using CefSharp;
|
using CefSharp;
|
||||||
using CefSharp.WinForms;
|
using CefSharp.WinForms;
|
||||||
using SafeExamBrowser.Applications.Contracts;
|
using SafeExamBrowser.Applications.Contracts;
|
||||||
|
@ -119,6 +120,7 @@ namespace SafeExamBrowser.Browser
|
||||||
public void Terminate()
|
public void Terminate()
|
||||||
{
|
{
|
||||||
logger.Info("Initiating termination...");
|
logger.Info("Initiating termination...");
|
||||||
|
AwaitReady();
|
||||||
|
|
||||||
foreach (var instance in instances)
|
foreach (var instance in instances)
|
||||||
{
|
{
|
||||||
|
@ -145,6 +147,15 @@ namespace SafeExamBrowser.Browser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AwaitReady()
|
||||||
|
{
|
||||||
|
// We apparently need to let the browser finish any pending work before attempting to reset or terminate it, especially if the
|
||||||
|
// reset or termination is initiated automatically (e.g. by a quit URL). Otherwise, the engine will crash on some occasions, seemingly
|
||||||
|
// when it can't finish handling its events (like ChromiumWebBrowser.LoadError).
|
||||||
|
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateNewInstance(string url = null)
|
private void CreateNewInstance(string url = null)
|
||||||
{
|
{
|
||||||
var id = ++instanceIdCounter;
|
var id = ++instanceIdCounter;
|
||||||
|
@ -353,6 +364,7 @@ namespace SafeExamBrowser.Browser
|
||||||
private void Instance_ResetRequested()
|
private void Instance_ResetRequested()
|
||||||
{
|
{
|
||||||
logger.Info("Attempting to reset browser...");
|
logger.Info("Attempting to reset browser...");
|
||||||
|
AwaitReady();
|
||||||
|
|
||||||
foreach (var instance in instances)
|
foreach (var instance in instances)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue