2012-01-22 54 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(); 
      }