反复调用3500次左右出错,GDI和Icon比较熟的来
try
{
Int32 I=0;
while(true)
{
System.Drawing.Bitmap bmpT=new Bitmap(16,16);
//下面几行去掉则不出错!
for(Int32 i=0;i<10;i++)
{
bmpT.SetPixel(rndT.Next(16),rndT.Next(16),
System.Drawing.Color.FromArgb(rndT.Next(255),rndT.Next(255),rndT.Next(255)));
}
//就是上面几句。。。
System.Drawing.Graphics gpT=System.Drawing.Graphics.FromImage(bmpT);
this.Icon =System.Drawing.Icon.FromHandle(bmpT.GetHicon());
gpT.Dispose();
bmpT.Dispose();
I++;
}
}
catch (Exception E)
{
System.Console.WriteLine("I="+I);
System.Console.WriteLine(E.Message);
this.Close();
}
==============================================
I=3320
GDI+ 中发生一般性错误。
程序“[588] Study.exe”已退出,返回值为 0 (0x0)。
==============================================
怎么回事????????