サードパーティのInprocCOMサーバーがあります。私が呼び出す関数の1つは、特定のタイプのエラーをトラップすると、エラーメッセージダイアログボックスを表示します。問題は、データをまとめて処理しようとしていることです。使用しているデータソースが原因で、エラーダイアログが頻繁に表示されます。これは、1000個のダイアログボックスを生成した場合は問題になりませんが、代わりにブロックされ、[OK]を押すまで関数は戻りません。
ダイアログが表示されないようにする、またはプログラムで[OK]を押すにはどうすればよいですか?
[OK]を押すのを待っているコールスタックのコピーを次に示します。
[ネイティブ移行への管理] > System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID、int reason、int pvLoopData)2198行目+ 0x1eバイトC# System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason、System.Windows.Forms.ApplicationContext context)行3422 + 0x1bバイトC# System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason、System.Windows.Forms.ApplicationContext context)3306行目+ 0xcバイトC# System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)1495行目+ 0x31バイトC# UniversalDataImporter.exe!UniversalDataImporter.Program.Main()18行目+ 0x1dバイトC# [ネイティブからマネージドへの移行] [ネイティブ移行への管理] mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile、System.Security.Policy.Evidence assemblySecurity、string [] args)2023行目+ 0x18バイトC# Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()+0x27バイト mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)行68 + 0x27バイトC# mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContextexecutionContext、System.Threading.ContextCallbackコールバック、オブジェクト状態、boolpreserveSyncCtx)行581 + 0xdバイトC# mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executeContext、System.Threading.ContextCallbackコールバック、オブジェクト状態、boolpreserveSyncCtx)行530 + 0xdバイトC# mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executeContext、System.Threading.ContextCallbackコールバック、オブジェクト状態)行519 + 0xeバイトC# mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()行105 + 0x20バイトC# [ネイティブからマネージドへの移行]
私はそれが役立つとは思えませんが(メッセージボックス、サブスクライブするイベント、または関数への他のオーバーロードを無効にするオプションはありません)、ここに呼び出し元のコードがあります。
for (int i = 1; i <= recordCount; i++)
{
//If the dialog shows up the following line blocks till you press OK.
var values = _comServer.GetValues(fileHandle, i);
sqlDataConsumer.LoadRow(values);
}