ちょっと、私のVisual StudioがクラッシュしてしまったUserControlがあります。 だから私はVSの別のインスタンスを実行し、他のVSをデバッグし、これは私が考え出しものです:ここでは Visual Studioがクラッシュします。 - 列挙子がインスタンス化された後にコレクションが変更されました
Collection was modified after the enumerator was instantiated.
は私の配列です:
private static Color[] colors =
{
Color.FromArgb(155, 188, 255), // 40000
Color.FromArgb(156, 189, 255), // 39500
Color.FromArgb(157, 188, 255), // 39000
Color.FromArgb(156, 189, 254), // 38500
};
そして、ここでタマンをクラッシュし、私のループである
Visual Studioのデザイナがクラッシュpublic Heater()
{
InitializeComponent();
this.tarTemp = this.curTemp;
new Thread(() => UpdateTemp(true)).Start();
}
private delegate void UpdateTempDelegate(bool loop);
private void UpdateTemp(bool loop)
{
if (lblTemp.InvokeRequired)
{
UpdateTempDelegate del = new UpdateTempDelegate(UpdateTemp);
lblTemp.Invoke(del, loop);
}
else
{
do
{
lblTemp.Text = curTemp + C;
if (curTemp >= 0)
{
int i = curTemp - 10;
if (i < 0)
i = 0;
if (i > colors.Length - 1)
i = colors.Length - 1;
this.BackColor = colors[i]; // I'M CRASHING !!!
}
} while (loop && !this.Disposing);
}
}
ラインはthis.BackColor = colors[i];
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
Stack:
at System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource)
at System.Collections.Generic.SortedList`2+SortedListValueEnumerator[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at Microsoft.VisualStudio.Shell.ServiceProviderHierarchy.GetService(System.Type)
at System.ComponentModel.Design.ServiceContainer.GetService(System.Type)
at System.ComponentModel.Design.DesignerHost.GetService(System.Type)
at System.ComponentModel.Design.DesignerHost+Site.System.IServiceProvider.GetService(System.Type)
at System.Windows.Forms.Control.get_AmbientPropertiesService()
at System.Windows.Forms.Control.get_BackColor()
at System.Windows.Forms.Control.set_BackColor(System.Drawing.Color)
at Multiplier.Heater.UpdateTemp(Boolean)
at Multiplier.Heater.<.ctor>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
:
すべてのスレッドが同じライン上に停止し
...ここ
this.BackColor = colors[i];
がEventViewerクラッシュログがある:ここ
は、実行中のスレッドの画像です
これは私が今までに遭遇した最も奇妙なことです。 ヘルプはうまくいくはずです。
あなたは近くにいました:Pは!DesignModeのバラックにスレッドの作成を配置することは、私もWhileループを配置しただけではありませんでした:) Thx! – Danpe