Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not thread safe #1

Open
TimothyKhouri opened this issue Dec 23, 2014 · 1 comment
Open

Not thread safe #1

TimothyKhouri opened this issue Dec 23, 2014 · 1 comment

Comments

@TimothyKhouri
Copy link
Owner

Just documenting for anyone coming behind and using this... but if you use multiple threads (aka - if you are using asp.net, you should pay attention), you will need to lock an object for now and only allow one thread at a time to access the ConvertToPdf method.

@TimothyKhouri
Copy link
Owner Author

Here is a workaround for the thread-saftey issue in case you want to use this in ASP.NET or some other multi-threaded environment (until the issue is fixed, if ever)

private static object _myLock = new object();

public static byte[] MyThreadSafeMethod(string html)
{
    lock (_myLock)
    {
        return HtmlToXConverter.ConvertToPdf(html);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant