Making a Part of code to be executed once

  • Thread starter Thread starter sravan_reddy001
  • Start date Start date
S

sravan_reddy001

I hav a method which is called repeatedly. i want a part of that code
to be executed once.

this can be possible with the help of ---- if() and a flag ---- is
there any other method to do this. That part of code should be present
in the method.
 
What are you exactly trying to do? What´s the matter of using a flag?
I think you can encapsulate this behavior and provide an event for the
first time (like an OnInit event)

Diego
 
this is what i want to do...
method()
{
--------
if(flag)
{
code; and flag=false
}
----
}

making this will execute the code only once and i'm never going to
change the flag to true(flag is boolean)

i can't use the init() method... the code is linked with the the
method's operation.
Is there any other method??
 
this is what i want to do...
method()
{
--------
if(flag)
{
code; and flag=false
}
----

}

making this will execute the code only once and i'm never going to
change the flag to true(flag is boolean)

i can't use the init() method... the code is linked with the the
method's operation.
Is there any other method??

Hi,

Why use other method? :)

Moty
 
Hi,

sravan_reddy001 said:
this is what i want to do...
method()
{
--------
if(flag)
{
code; and flag=false
}
----
}

making this will execute the code only once and i'm never going to
change the flag to true(flag is boolean)

i can't use the init() method... the code is linked with the the
method's operation.
Is there any other method??

What is wrong with that?
If you are worried about performance, forget it. A simple if has no
repercusion overall.
 

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

Back
Top