且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebService 调用异常:线程被中止

更新时间:2023-12-05 10:01:28

我有类似的问题.我认为 IIS 正在终止您的线程花费太长时间.根据您的描述我有一个循环遍历数据库中的许多付款行",您可以重构您的应用程序以单独处理每一行.创建一个 webmethod 将行发送到客户端,然后让客户端一次迭代一个事务并在不同的 webmethod 中处理它们.然后您可以处理发生的异常并继续进行.您甚至可以使用 Parallel.ForEach 一次处理多个

I have a similar issue. I think IIS is terminating your thread for taking too long. From your description "I have a foreach loop that iterates through many payment rows in a database", you may be able to restructure your app to process each row individually. Create a webmethod to send the rows to the client, then have the client iterate the transactions one at a time and process them in a different webmethod. Then you can handle exceptions that occur and keep going. You may even be able to process many at once using Parallel.ForEach