来自AWSSDK的.net

时间:2015-09-03 18:26:43

标签: aws-sdk

我的代码中遇到了这个奇怪的异常。它适用于VS 2015,.net 4.6和AWSSDK Nuget Package。这是在本地运行单元测试时抛出的。

System.Threading.ThreadAbortException occurred
  HResult=-2146233040
  Message=Thread was being aborted.
  Source=mscorlib
  StackTrace:
       at System.Threading.WaitHandle.WaitOneNative(SafeHandle waitableSafeHandle, UInt32 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
       at System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
       at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext)
       at System.Threading.WaitHandle.WaitOne()
       at Amazon.Runtime.Internal.Util.BackgroundDispatcher`1.Run() in d:\Jenkins\workspace\build-sdkandtools\sdk\src\AWSSDK_DotNet35\Amazon.Runtime\Internal\Util\Dispatcher.cs:line 147
  InnerException: 

之前有人这样吗?我怎么能阻止这种情况发生?

感谢。

1 个答案:

答案 0 :(得分:0)

使用AWSSDK for .NET时遇到了类似的错误,特别是class Settings: def __init__(self, engine, stackview): self.engine = engine self.stackview = stackview def load(self): self.component = QQmlComponent(self.engine) self.component.loadUrl(QUrl('QML/Settings/Settings.qml')) self.settings = self.component.create() # Attach to signals, etc. self.stackview.push(self.settings) 。在我的例子中,当在C#AWSSDK.CloudSearchDomain v3.1.0.6语句中调用AWSSDK *Async方法时,似乎引发了错误。具体来说,在使用线程中止调用Parallel.Foreach时失败了:

UploadDocumentsAsync

虽然成功了:

Parallel.ForEach<AttachmentObject>(files, async file => {
  ...
  var request = new Amazon.CloudSearchDomain.Model.UploadDocumentsRequest() {...}
  var response = await client.UploadDocumentsAsync(request);
});