Wie stoppe ich eine Stoppuhr im "Catch" -BlockC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Wie stoppe ich eine Stoppuhr im "Catch" -Block

Post by Anonymous »

Ich versuche, die Reaktionszeit einer Oracle -Abfrage zu erhalten und Stopwatch zu verwenden, um dies zu erreichen.

Code: Select all

bool bSuccess = false;
int iRetryCnt = 0;
TimeSpan elasped = TimeSpan.Zero;

while (!bSucess && iRetryCnt < 3)
{
try
{
var timer = System.Diagnostics.StopWatch.StartNew();


timer.Stop();
elapsed = timer.Elapsed;

bSuccess = true;
}
catch
{
iRetryCnt++;
// Assuming db connection timeout happens and it falls here.
// Can't stop timer here and calculate elapsed; "timer" doesn't exist
}
}
Ich bin mir nicht sicher, ob es möglich ist, eine Stoppuhr außen zu initialisieren /

Code: Select all

catch
.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post