.net线程的HTML敏捷包对于在并行线程中使用单个HtmlDocument实例的只读访问是安全的吗? [英] Is HTML Agility Pack for .net thread safe for read-only access using a single HtmlDocument instance across parallel threads?

查看:130
本文介绍了.net线程的HTML敏捷包对于在并行线程中使用单个HtmlDocument实例的只读访问是安全的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML敏捷包对.net线程来说是安全的,可以在并行线程中使用单个HtmlDocument实例进行只读访问吗?



我刮了一个页面,我需要的数据的部分页面可能会很慢,所以我想一次使用Parallel c#库来抓取页面的多个部分。

解决方案

div>

我在我的多线程程序中使用了HTMLAgilityPack,它工作正常。
我认为你只需要通过使用锁块等方法来保证程序安全。

例如
lock(asyncObject)
{
//做HTML处理...
}


Is HTML Agility Pack for .net thread safe for read-only access using a single HtmlDocument instance across parallel threads?

I am scraping a single page but scraping some parts of page for how I need the data can be slow so I want to scrape multiple sections of the page at one time using Parallel c# library.

解决方案

I've used HTMLAgilityPack in my multithreading program and it works fine. I think you only need to safe your program by using some methods like locking blocks.

e.g lock(asyncObject) { // do html processing... }

这篇关于.net线程的HTML敏捷包对于在并行线程中使用单个HtmlDocument实例的只读访问是安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆