stacked overflow problem med kode stump
Hejsa,nogle der kan komme med et bud på hvorfor jeg ret ofte for stacked overflow exeption i denne kode.
jeg mener ikke den er i en uendelig løkke
public static void Capture(Point SourcePoint, Point DestinationPoint, Rectangle SelectionRectangle, string FilePath)
{
bool tryAgain = false;
int trymore = 0;
do
{
try
{
using (Bitmap thisbitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height))
{
using (Graphics g = Graphics.FromImage(thisbitmap))
{
g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);
}
string savePath = "C://temp/temp/123turn.bmp";
try
{
using (FileStream dstream = new FileStream(savePath, FileMode.Create))
{
thisbitmap.Save(dstream, ImageFormat.Bmp);
dstream.Close();
}
tryAgain = false;
trymore = 0;
}
catch
{
trymore = trymore + 1;
if (trymore <= 1)
tryAgain = true;
else
tryAgain = false;
}
}
}
catch
{
}
}
while (tryAgain);
}