2012-01-22 40 views
0

下面的代码:网站从未加载在awesonium

static void Main(string[] args) 
    { 
     Semaphore loadFinished = new Semaphore(0, 1); 

     WebCore.Initialize(new WebCoreConfig() { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" }); 

     using (WebView webView = WebCore.CreateWebView(1200, 800)) 
     { 
      webView.LoadCompleted += (a, b) => 
      { 
       loadFinished.Release(); 
      }; 
      webView.LoadURL("http://store.apple.com/ca/browse/home/shop_iphone/family/iphone/iphone4s"); 

      loadFinished.WaitOne(); 

      webView.Render().SaveToJPEG(@"D:\Users\menkaur\Documents\stream\2012\apple-store\awesonium\result.jpg", 100); 
     } 

     // Announce. 
     Console.Write("Hit any key to see the result..."); 
     Console.ReadKey(true); 

     // Start the application associated with .png files 
     // and display the file. 
     Process.Start(@"D:\Users\menkaur\Documents\stream\2012\apple-store\awesonium\result.jpg"); 

     // Shut down Awesomium before exiting. 
     WebCore.Shutdown(); 

     Console.ReadKey(true); 
    } 

网站从未加载;然而,从正常的铬看,它看起来很好;此外,我已经使用google.com测试了该代码,并且它也可以很好地工作。

什么可能是错误的?

回答

1

好的。这里的解决方案:

  while (!loadFinished.WaitOne(100)) 
      { 
       WebCore.Update(); 
      }