Advertisement
andruhovski

Aspsoe.HTML

Nov 1st, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using Aspose.Html;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Aspose.HTML.Demo
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             var document = new HTMLDocument();
  16.             Thread thread = null;            
  17.             Console.WriteLine("Thread id={0}", Thread.CurrentThread.ManagedThreadId);
  18.             document.OnReadyStateChange += (sender, @event) =>
  19.             {
  20.                 Console.WriteLine(document.ReadyState);
  21.                 if (thread == null)
  22.                     thread = Thread.CurrentThread;
  23.                 if (document.ReadyState == "complete")
  24.                 {
  25.                     Console.WriteLine("Count={0}", document.Body.GetElementsByTagName("p").Count());
  26.                     thread.Abort();
  27.                 }                
  28.             };
  29.             document.Navigate("https://asposedemo20170904120448.azurewebsites.net/");
  30.             while (thread == null)
  31.             {
  32.                 Thread.Sleep(10);
  33.             }
  34.             Console.WriteLine("Thread id={0}",thread.ManagedThreadId);
  35.             thread.Join();
  36.             Console.WriteLine("Waiting for keypress...");
  37.             Console.ReadKey();      
  38.         }
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement