我正在使用Awesomium .Net 1.7.5.1并且我遇到了问题。当我创建两个(或更多)没有默认代理参数的WebView时,我无法同时将页面加载到它们中。当我试图这样做时 - 只有一个WebView正确地加载其页面,而其他人是#34; die":他们没有触发事件,没有完成加载等。 此代码可以重复此问题:
private static void Main()
{
var isWebCoreRunning = false;
var webCoreThread = new Thread(() =>
{
WebCore.Initialize(new WebConfig());
WebCore.Run((sender, args) => isWebCoreRunning = true);
}) {Name = "WebCore Thread", IsBackground = true};
webCoreThread.Start();
while (!isWebCoreRunning)
Task.Delay(10).Wait();
var proxyConfig = String.Format("{0}:{1}", "proxyHost", proxyPort);
var webView1 = WebCore.DoWork(() =>
{
var webPreferences = new WebPreferences { ProxyConfig = proxyConfig };
var webSession = WebCore.CreateWebSession(webPreferences);
return WebCore.CreateWebView(100, 100, webSession);
});
var webView2 = WebCore.DoWork(() =>
{
var webPreferences = new WebPreferences { ProxyConfig = proxyConfig };
var webSession = WebCore.CreateWebSession(webPreferences);
return WebCore.CreateWebView(100, 100, webSession);
});
webView1.LoginRequest += OnLoginRequest;
webView2.LoginRequest += OnLoginRequest;
webView1.LoadingFrameComplete += (sender, args) => Console.WriteLine("X");
webView2.LoadingFrameComplete += (sender, args) => Console.WriteLine("X");
WebCore.QueueWork(() => webView1.Source = new Uri("https://www.google.ru/"));
WebCore.QueueWork(() => webView2.Source = new Uri("https://www.google.ru/"));
Console.ReadKey();
}
private static void OnLoginRequest(object sender, LoginRequestEventArgs e)
{
e.Username = "proxyLogin";
e.Password = "proxyPassword";
e.Handled = EventHandling.Modal;
e.Cancel = false;
}
在这里,我们只会得到一个" X"在控制台。当我不使用代理时,一切正常。有人能指出我的问题是什么吗?这是一个错误(但它是如何仍然未知的那么奇怪)或者我错过了什么?