Stopwatch.Stop Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir aralık için geçen süreyi ölçmeyi durdurur.
public:
void Stop();
public void Stop();
member this.Stop : unit -> unit
Public Sub Stop ()
Örnekler
Aşağıdaki örnekte, uygulamanın yürütme süresini ölçen bir zamanlayıcıyı durdurmak için yönteminin nasıl kullanılacağı Stop gösterilmektedir.
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
}
}
Imports System.Diagnostics
Imports System.Threading
Class Program
Shared Sub Main(ByVal args() As String)
Dim stopWatch As New Stopwatch()
stopWatch.Start()
Thread.Sleep(10000)
stopWatch.Stop()
' Get the elapsed time as a TimeSpan value.
Dim ts As TimeSpan = stopWatch.Elapsed
' Format and display the TimeSpan value.
Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
Console.WriteLine( "RunTime " + elapsedTime)
End Sub
End Class
Açıklamalar
Tipik Stopwatch bir senaryoda yöntemini çağırır Start , ardından sonunda yöntemini çağırırsınız Stop ve ardından özelliğini kullanarak Elapsed geçen süreyi denetlersiniz.
yöntemi geçerli Stop zaman aralığı ölçümlerini sonlandırır. Çalışmayan bir Stopwatch durdurulması zamanlayıcı durumunu değiştirmez veya geçen süre özelliklerini sıfırlamaz.
Bir Stopwatch örnek birden fazla aralık ölçtüyse, Stop yöntem geçen zaman ölçüsünü duraklatmaya eşdeğerdir. Devam eden Start bir çağrı, geçerli geçen saat değerinden zamanı ölçmeyi sürdürür. Reset Bir Stopwatch örnekte geçen kümülatif süreyi temizlemek için yöntemini kullanın.