Hi All,
I have cured one problem with a bit of software but created a side issue, deep breath the code is below:
}
void Result()
{
float Value_Extract = 0;
int Lenght = 0;
string ValueToBeExtracted;
Thread.Sleep(1500);
MessageBox.Show(rtbIncoming.Text);
Lenght = ((rtbIncoming.TextLength)-3);
ValueToBeExtracted = rtbIncoming.Text.Substring(1,Lenght-2);
float.TryParse(ValueToBeExtracted,out Value_Extract);
if (Value_Extract < 0.45)
{
MessageBox.Show("Too Low", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (Value_Extract > 0.55)
{
MessageBox.Show("Too High", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("Pass", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Now it works well enough but the message box after the Thread<dot>Sleep. It show the rich text box contents which are blank to act as a time waster for the thing to return a value. With that box it works, without it BANG!
What I have tried:
A timer to waste time along the lines of
var sw = new StopWatch();
var maxTime = TimeSpan.FromMinutes(5);
sw.Start();
for (int i=0; i < 100; i++)
{
RunfunctionA();
if(sw.Elapsed <= maxTime)
{
RunfunctionB();
break;
}
}
I'm not too sure if this will cause a stop in the example 5 mins I need 2 - 3 seconds at most, altering this from minutes to seconds appears to break some thing I'm not sure what or even if this will work!
Am I going about this the right way?