I'm building a captcha like functionality and I have a method to draw random lines
private Graphics DrawRandomLines(Graphics g)
{
SolidBrush green = new SolidBrush(Color.Green);
int count = 0;
for (int i = 0; i < 20; i++)
{
g.DrawLines(new Pen(green, 2), GetRandomPoints());
count++;
}
return g;
}
The problem is only one line is painted on my graphics when I'm launching web app. But when I'm launching in debug mode loop is working and I'm getting all 20 lines painted.
Here is GetRandomPoints
private Point[] GetRandomPoints()
{
Random rand = new Random();
Point[] points = { new Point(rand.Next(0, 100),
rand.Next(0, 30)),
new Point(rand.Next(0, 100),
rand.Next(0, 30)) };
return points;
}