atifaziz / Hazz

CSS Selectors (via Fizzler) for HtmlAgilityPack (HAP)
Other
63 stars 7 forks source link

HtmlNodeSelection.CachableCompile fails on secondary threads #3

Closed atifaziz closed 6 years ago

atifaziz commented 6 years ago

HtmlNodeSelection.CachableCompile throws an instance of NullReferenceException when called from any secondary thread, as demonstrated below:

static void Main()
{
    void Test()
    {
        Console.WriteLine("Running on thread #" + Thread.CurrentThread.ManagedThreadId);
        HtmlNodeSelection.CachableCompile("p");
    }
    Test(); // succeeds
    var t = new Thread(Test);
    t.Start(); // fails
    t.Join();
}