我有以下代码在 Method2 中生成两个线程,如下所示
Thread[] arrThreads = new Thread[2];
Thread t1 = new Thread(() =>
{
value1 = this.Method1(<some params>);
});
t1.Start();
arrThreads[0] = t1;
Thread t2 = new Thread(() =>
{
value2 = this.SomeOtherMethod(<some params>);
});
t2.Start();
arrThreads[1] = t2;
// Code which waits for both threads to get over OR for a threshold, whichever comes first!
这在我的开发中运行良好。但是在发布到 IIS 生产机器时,遇到以下错误。
at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
at System.Data.RBTree`1.get_Item(Int32 index)
at System.Data.DataRowCollection.get_Item(Int32 index)
at Namespace.Class.Method1(params) in D:\XXXX\Class.cs:line 11309
at Namespace.Class.<>c__DisplayClasse.<Method2>b__a() in D:\XXXX\Class.cs:line 11687
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
任何人都可以帮我解决这个错误吗?提前致谢。