特别是,我必须以最快和最可靠的方式从Lotus Notes文件中提取所有消息和附件.可能相关的另一点是我需要从辅助线程执行此操作.
编辑
谢谢你的答案 - 两者都很好.我应该提供更多背景资料.
我们目前有一个使用Notes COM API的后台线程的WinForms应用程序.
然而它似乎不稳定.(当然可能是我们做错了.)例如,我们发现我们必须在主线程上预先初始化Notes会话,否则对后台线程上的session.CreateDXLExporter()的调用会引发异常.
我真的很讨厌那个NotesSession COM对象.
您不能在其初始化的线程之外的其他线程中使用它..NET中的线程是光纤,真正的底层线程可能随时发生变化.
所以我建议在使用块中以这种方式使用它:
Imports Domino Imports System.Threading Public Class AffinitedSession Implements IDisposable Private _session As NotesSession Public Sub New(ByVal pass As String) Thread.BeginThreadAffinity() _session = New NotesSession() _session.Initialize(pass) End Sub Public ReadOnly Property NotesSession() As NotesSession Get Return _session End Get End Property Private disposedValue As Boolean = False ' To detect redundant calls ' IDisposable Protected Overridable Sub Dispose(ByVal disposing As Boolean) If Not Me.disposedValue Then If disposing Then ' TODO: free other state (managed objects). End If ' TODO: free your own state (unmanaged objects). ' TODO: set large fields to null. _session = Nothing Thread.EndThreadAffinity() End If Me.disposedValue = True End Sub #Region " IDisposable Support " ' This code added by Visual Basic to correctly implement the disposable pattern. Public Sub Dispose() Implements IDisposable.Dispose ' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above. Dispose(True) GC.SuppressFinalize(Me) End Sub #End Region End Class
注意Thread.BeginThreadAffinity()和Thread.EndThreadAffinity()
那些是你的朋友.
干杯!