Wie stoppe ich eine Stoppuhr im "Catch" -Block

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie stoppe ich eine Stoppuhr im "Catch" -Block

by Anonymous » 23 Apr 2025, 06:37

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
.

Top