Link to home
Start Free TrialLog in
Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden

asked on

comparing a function execution in a loop and outside loop in C#.

Hi;

I have a rather complex function call in a loop and want to check the state of the state of the objects affected by those function, comparing it in and outside the loop.

Any feasible way to do to compare?

Regards.
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

No problem.
Run one inside of a separate thread then use some locking technique in the object to prevent dual access.

ps.  Your question doesn't really make sense, I suspect what I suggest isn't really what you want to do even though it is what you ask for.
Avatar of jazzIIIlove

ASKER

Hi;

I want to find the changes of the objects that the function may cause a change inside and outside of the loop.

Regards.
OK, my first comment still does what you want.

ps.
Say your object has a int value.  Setting it to 42 will result in the object containing 42, it doesn't matter if you set that inside or outside of a loop.
My object has several objects in it which may get affected.

Can you provide a simple code for this locking inside and outside of the loop?
There are various possibilities to prevent simultaneous access to an object.  This is one method:

lock Statement (C# Reference), msdn reference site,

http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx
but actually this is a comparison case. I mean I just need to test the behaviour of the same function inside and outside of the loop..
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial