- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 Parallel.ForEach
在多个线程上工作,每次迭代都使用一个新的 EF5 DbContext,所有这些都包含在一个 TransactionScope 中,如下所示:
using (var transaction = new TransactionScope())
{
int[] supplierIds;
using (var appContext = new AppContext())
{
supplierIds = appContext.Suppliers.Select(s => s.Id).ToArray();
}
Parallel.ForEach(
supplierIds,
supplierId =>
{
using (var appContext = new AppContext())
{
Do some work...
appContext.SaveChanges();
}
});
transaction.Complete();
}
运行几分钟后,它会抛出 EntityException“底层提供程序在打开时失败”,内部细节如下:
“SQL Server 数据库引擎的实例此时无法获取 LOCK 资源。当事件用户较少时重新运行您的语句。请数据库管理员检查此实例的锁和内存配置,或检查长时间运行的事务。”
有谁知道造成这种情况的原因或如何预防这种情况?谢谢。
最佳答案
您还可以尝试使用 new ParallelOptions { MaxDegreeOfParallelism = 8 }
在 Parallel.ForEach()
方法中设置并发任务的最大数量(将 8 替换为任意值你想限制它。
参见 MSDN了解更多详情
关于c# - 并行线程中的多个 dbcontext,EntityException "Rerun your statement when there are fewer active users",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14873042/
我正在尝试通过 UART 电缆将设备(血氧计)连接到 Android 智能手机。所以我需要构建一个能够从此设备读取数据的应用程序。为此,我使用 Android Things,但我无法运行此应用程序,因
我担心将来运行的代码可能会失败。我用 tidyverse 看过这个运行良好但一段时间后返回错误的函数,因为它们已被 Defunct .为了给出一些可重现的例子,试试这段来自 How to make a
我最近注意到 maven 生成的 Scala 编译器警告如下所示: [警告] 警告:有 4 个弃用警告;使用 -deprecation 重新运行以获取详细信息 [警告] 警告:有 3 个功能警告;使用
我正在数据工厂中定义管道,我纠正了一些错误。第一个事件是调用 usql 脚本进行一些聚合,我更改了脚本很多时间,但错误仍然是: [{"errorId":"E_CSC_USER_SYNTAXERROR"
map 问题 我想映射数组,该数组重新运行函数tree(...)。然而,它返回了一系列的 promise ,这不是我所期望的。我需要它是异步的。 我期望返回的是一个具有以下格式的数组: { 姓名: '
不幸的是,MStest/VStest 没有本地测试重新运行逻辑 我正在尝试实现这样的自定义逻辑: 测试部分: static int testNum = 1; [TestMethod]
我可以在更正文件中的错误后重新启 Action 业并仅处理跳过的项目吗?我正在阅读文档,目前没有发现这种可能性。如果作业失败,您可以重新启 Action 业,但我想在完成一些跳过的项目后重新启 Act
我用 Spring 开发了一个应用程序。我有一个创建线程的 bean,但在执行此线程期间,在运行时,JVM 抛出 OutOfMemoryError - Java 堆空间。 我想问的是以下解决方案是否适
我有一个 postman 请求,顺序如下 获取请求 获取请求 POST 请求 POST 请求<<< POST请求<<<只需要重复4,5,6 - 10次 POST 请求<<< POST 请求 4、5 和
OOZIE REST API RERUN - START 作业功能不起作用 你好, 我想启动 Oozie 的作业抛出 REST API(CDH 5.3.1 中的 Oozie 4.0.0 版),但该作业
我无法在任何 Android 设备上运行我的 Android 项目。 我在 android studio 上遇到错误。我的项目正在构建和编译,没有任何错误。 正在附加 screenshot 最佳答案
我正在运行 Cucumber 测试(在 Jenkins 中使用 Maven)并将失败的场景输出到 target/rerun.txt,按照以下说明:https://github.com/cucumber
我正在使用 Python 和 Selenium 2.44。当测试失败时,我不能在调试时将失败前的所有代码都取消注释,因为不会为浏览器声明驱动程序。因此,每当我尝试修复某些东西时,我总是必须在测试用例中
我有一个页面加载一组复杂的表单。在这组表单中,有密码字段。这些密码字段具有显示/隐藏切换开关,当单击其中任何一个时,所有密码字段都会被 DOM 中的等效项替换,其类型在“文本”和“密码”之间切换,以方
我正在使用 Parallel.ForEach 在多个线程上工作,每次迭代都使用一个新的 EF5 DbContext,所有这些都包含在一个 TransactionScope 中,如下所示: using
我有一个包含许多测试的 JUnit 测试类。为了增加场景覆盖率,我们测试中的一些数据是随机的,这意味着它可能在各个测试运行之间采用一系列值,例如: protected MonthlyAmountWit
通过这最后一条消息,cargo 想告诉我什么? :error: test failed, to rerun pass '--lib'甚至 Cargo 书中也有测试示例显示了这个确切的最后一行,没有解释
我在 Android Studio 上遇到了一个非常令人沮丧的行为,更新到最新版本(3.1.3,构建编号#AI-173.4819257),gradle 插件版本 3.1.3。发生的事情是,在运行基于
我有一个发布定义,我想在同一步骤中使用“覆盖参数”和“重新运行失败的测试”,这看起来像这样: 当我只指定了覆盖参数时,一切正常,没有问题。当我启用“重新运行失败的测试”选项时,我在版本中收到以下错误:
我正在试着在我的回购中得到某一特定分支机构最近的所有运行记录。然后我希望能够将它们联系起来。。例如,假设我有5次运行(01,02,03,04,05),01-03是新运行,04是01的重新运行,05是0
我是一名优秀的程序员,十分优秀!