Solved

timing of an event

Posted on 2009-05-19
1
151 Views
Last Modified: 2013-12-17
I am using vb.net with silverlight but anyone  with vb.net knoiwledge can answer this.

I have a game loop and when an object moves off another object I need to know.

I can use either an event to inidicate when this happens or a class variable to test when this happens.

1)If I use an event, then during the middle of some procedure the vent can be raised making planning for this code hard to do. So the event can
happen at a time that could be hard to work in.

2) If I test a variable to see if this has happened I can work it in during a lot easier  in the game loop.

what do i do?
0
Comment
Question by:jagguy
1 Comment
 
LVL 16

Accepted Solution

by:
CuteBug earned 500 total points
ID: 24430917
If you do not want to handle the scenario, when one object moves off another object, in the middle of some procedure, then the best way would be to test the value of the variable which will indicate that the object has moved.

But in this case, there may be a delay when you respond to the object movement. Suppose Object A moves off ObjectB. So it sets a variable called MovedOff (say).

But the place where you check the status of the variable might not be reached immediately. The application might be busy executing the statements preceding it.


So if you want to respond immediately to the object movement, use events.
Otherwise you can use the variable.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now