Problems Only When Using Run Without Debugging

W

Will

Hi Everyone,

I have been having a bizarre problem when I do Run Without Debugging
(I have been doing this do to the intensity of some code which runs
slow when Debugging). When I run without debugging, the application
appears hangs on this code:


private static CCPix ClusterListHasPoint(Point ring,
List<CCPix> tileList)
{
for (int i = 0; i < tileList.Count; i++)
{
if (tileList.Location.X == ring.X &&
tileList.Location.Y == ring.Y)
{
return tileList;
}
}
return null;
}


If the if statement is taken out, the loop does eventually finish
without debugging... but ridiculously longer.


With Debugging on, it does not cause a problem. Does anyone have any
thoughts? I've been looking around the web without too much luck :-\ I
have a feeling I am missing something small.


Thanks,

Will
 
G

Gilles Kohl [MVP]

Will,
I have been having a bizarre problem when I do Run Without Debugging
(I have been doing this do to the intensity of some code which runs
slow when Debugging). When I run without debugging, the application
appears hangs on this code:


private static CCPix ClusterListHasPoint(Point ring,
List<CCPix> tileList)
{
for (int i = 0; i < tileList.Count; i++)
{
if (tileList.Location.X == ring.X &&
tileList.Location.Y == ring.Y)
{
return tileList;
}
}
return null;
}


If the if statement is taken out, the loop does eventually finish
without debugging... but ridiculously longer.


Not sure I parse this latest statement correctly - what exactly is your problem - does the following loop:

for (int i = 0; i < tileList.Count; i++)
{
}

with the if statement removed, really take long?
With Debugging on, it does not cause a problem.
Does anyone have any
thoughts? I've been looking around the web without too much luck :-\ I
have a feeling I am missing something small.

I can't see anything obviously wrong with the code posted. Of course, you've not posted all your code - is CCPix special
in some way? Of what type are "Location"? How high is tileList.Count?

Regards,
Gilles.
 
C

Chris Shepherd

Will said:
Hi Everyone,

I have been having a bizarre problem when I do Run Without Debugging
(I have been doing this do to the intensity of some code which runs
slow when Debugging). When I run without debugging, the application
appears hangs on this code: [...]
If the if statement is taken out, the loop does eventually finish
without debugging... but ridiculously longer.

If it's not performant enough, why not try a predicate and use tileList.Find()?

http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx

Here's an example of what I'm talking about:

public static Point HasPoint(Point tgt, List<Point> ptList)
{
Predicate<Point> p = new Predicate<Point>(
delegate(Point itm) { return (itm.X == tgt.X && itm.Y == tgt.Y); });

return ptList.Find(p);
}



Chris.
 
W

Will

Will said:
Hi Everyone,
I have been having a bizarre problem when I do Run Without Debugging
(I have been doing this do to the intensity of some code which runs
slow when Debugging). When I run without debugging, the application
appears hangs on this code: [...]
If the if statement is taken out, the loop does eventually finish
without debugging... but ridiculously longer.

If it's not performant enough, why not try a predicate and use tileList.Find()?

http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx

Here's an example of what I'm talking about:

public static Point HasPoint(Point tgt, List<Point> ptList)
{
    Predicate<Point> p = new Predicate<Point>(
       delegate(Point itm) { return (itm.X == tgt.X && itm.Y == tgt.Y); });

     return ptList.Find(p);

}

Chris.

Hi Chris,

Thanks for the post. Interestingly enough, I implemented the Predicate
example you referenced. Now instead of just becoming stuck, Running W/
O Debugging Does finish. It is still approximately executing about 40
times slower though... 240 seconds versus 6 seconds. At least it is a
step in the right direction.


Thanks again,

Will
 
C

Chris Shepherd

Will said:
Hi Chris,

Thanks for the post. Interestingly enough, I implemented the Predicate
example you referenced. Now instead of just becoming stuck, Running W/
O Debugging Does finish. It is still approximately executing about 40
times slower though... 240 seconds versus 6 seconds. At least it is a
step in the right direction.

How much data are you sifting through?
What is the data stored in (class, or struct could be important here)?

Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top