Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: Attributes in C# Pin
Pete O'Hanlon27-Apr-11 2:36
mvePete O'Hanlon27-Apr-11 2:36 
GeneralRe: Attributes in C# Pin
Not Active27-Apr-11 2:40
mentorNot Active27-Apr-11 2:40 
GeneralRe: Attributes in C# Pin
Wayne Gaylard27-Apr-11 0:55
professionalWayne Gaylard27-Apr-11 0:55 
AnswerRe: Attributes in C# Pin
ambarishtv28-Apr-11 5:45
ambarishtv28-Apr-11 5:45 
QuestionTime-Out for Loop in C#? Pin
JP_Rocks26-Apr-11 23:33
JP_Rocks26-Apr-11 23:33 
AnswerRe: Time-Out for Loop in C#? Pin
V.26-Apr-11 23:41
professionalV.26-Apr-11 23:41 
AnswerRe: Time-Out for Loop in C#? Pin
Wayne Gaylard26-Apr-11 23:48
professionalWayne Gaylard26-Apr-11 23:48 
AnswerRe: Time-Out for Loop in C#? Pin
Pete O'Hanlon27-Apr-11 0:02
mvePete O'Hanlon27-Apr-11 0:02 
First of all, there is no implicit loop operation that breaks out at a specified time interval. You'll have to code it yourself.

Secondly, as your loop depends on reaching a value or a timeout being reached, a for loop is not the appropriate choice - it is designed to work with a fixed number of iterations. In this case, I would choose to use a while loop instead. Then you could do something like the following:
C#
Stopwatch watch = new Stopwatch();
int count = 0;
do
{
  if (!watch.IsRunning)
  {
    watch.Start();
  }
  PerformSomeLongRunningOperation();
} while (++count < 10 && watch.Elapsed <= TimeSpan.FromSeconds(2) );
watch.Stop();

Forgive your enemies - it messes with their heads


My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility


QuestionXML Search Pin
DJ24526-Apr-11 20:40
DJ24526-Apr-11 20:40 
AnswerRe: XML Search Pin
Pete O'Hanlon26-Apr-11 22:04
mvePete O'Hanlon26-Apr-11 22:04 
GeneralRe: XML Search Pin
DJ24526-Apr-11 22:34
DJ24526-Apr-11 22:34 
GeneralRe: XML Search Pin
Pete O'Hanlon26-Apr-11 23:12
mvePete O'Hanlon26-Apr-11 23:12 
GeneralRe: XML Search Pin
PIEBALDconsult27-Apr-11 3:06
mvePIEBALDconsult27-Apr-11 3:06 
QuestionAdding missing header information in tiff files Pin
meeram39526-Apr-11 20:12
meeram39526-Apr-11 20:12 
AnswerRe: Adding missing header information in tiff files Pin
Pete O'Hanlon26-Apr-11 22:01
mvePete O'Hanlon26-Apr-11 22:01 
AnswerRe: Adding missing header information in tiff files Pin
Ravi Sant9-May-11 23:33
Ravi Sant9-May-11 23:33 
QuestionServices-like platform? Pin
NaNg1524126-Apr-11 11:23
NaNg1524126-Apr-11 11:23 
AnswerRe: Services-like platform? Pin
Justin Helsley26-Apr-11 12:50
Justin Helsley26-Apr-11 12:50 
GeneralRe: Services-like platform? Pin
NaNg1524126-Apr-11 21:34
NaNg1524126-Apr-11 21:34 
GeneralRe: Services-like platform? Pin
Justin Helsley27-Apr-11 21:29
Justin Helsley27-Apr-11 21:29 
QuestionFrequency-shifting Auditory Feedback Pin
mehdiattar26-Apr-11 9:51
mehdiattar26-Apr-11 9:51 
AnswerRe: Frequency-shifting Auditory Feedback Pin
Richard MacCutchan26-Apr-11 9:54
mveRichard MacCutchan26-Apr-11 9:54 
GeneralRe: Frequency-shifting Auditory Feedback Pin
AspDotNetDev26-Apr-11 12:59
protectorAspDotNetDev26-Apr-11 12:59 
GeneralRe: Frequency-shifting Auditory Feedback Pin
gavindon26-Apr-11 14:05
gavindon26-Apr-11 14:05 
AnswerRe: Frequency-shifting Auditory Feedback Pin
JP_Rocks26-Apr-11 23:33
JP_Rocks26-Apr-11 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.