이 페이지가 유용했습니까?
이 콘텐츠에 대한 여러분의 의견은 중요합니다. 의견을 알려주십시오.
추가 의견
1500자 남음
내보내기(0) 인쇄
모두 확장

Stopwatch 클래스

참고: 이 클래스는 .NET Framework 버전 2.0에서 새로 추가되었습니다.

경과 시간을 정확하게 측정하는 데 사용할 수 있는 일련의 메서드와 속성을 제공합니다.

네임스페이스: System.Diagnostics
어셈블리: System(system.dll)

public class Stopwatch
public class Stopwatch
public class Stopwatch

Stopwatch 인스턴스는 한 간격의 경과 시간 또는 여러 간격의 총 경과 시간을 측정할 수 있습니다. 일반적인 Stopwatch 시나리오에서는 Start 메서드를 호출한 다음 결국 Stop 메서드를 호출하고, 그런 다음 Elapsed 속성을 통해 경과 시간을 확인합니다.

Stopwatch 인스턴스는 실행 중이거나 중지된 상태입니다. Stopwatch의 현재 상태를 확인하려면 IsRunning을 사용합니다. Start를 사용하여 경과 시간 측정을 시작하고, Stop을 사용하여 경과 시간 측정을 중지합니다. Elapsed, ElapsedMilliseconds 또는 ElapsedTicks 속성을 통해 경과 시간 값을 쿼리합니다. 인스턴스가 실행 중이거나 중지되었을 때 경과 시간 속성을 쿼리할 수 있습니다. 경과 시간 속성은 Stopwatch가 실행 중인 동안에는 꾸준히 증가하고 해당 인스턴스가 중지되면 일정하게 유지됩니다.

기본적으로 Stopwatch 인스턴스의 경과 시간 값은 측정된 모든 시간 간격 합계와 같습니다. Start를 호출할 때마다 누적 경과 시간에서 시간 계산이 시작됩니다. Stop을 호출할 때마다 현재 간격 측정이 종료되고 누적 경과 시간 값은 고정됩니다. Reset 메서드를 사용하여 기존 Stopwatch 인스턴스에서 누적 경과 시간을 지울 수 있습니다.

Stopwatch는 내부 타이머 메커니즘에서 타이머 틱 수를 계산하여 경과 시간을 측정합니다. 설치된 하드웨어와 운영 체제에서 고정밀도 성능 카운터를 지원할 경우 Stopwatch 클래스는 해당 카운터를 사용하여 경과 시간을 측정합니다. 그렇지 않을 경우 Stopwatch 클래스는 시스템 타이머를 사용하여 경과 시간을 측정합니다. FrequencyIsHighResolution 필드를 사용하여 Stopwatch 타이밍 구현의 정밀도와 정확도를 확인할 수 있습니다.

Stopwatch 클래스는 관리 코드 내에서 타이밍 관련 성능 카운터를 조작하는 데 사용될 수 있습니다. 특히 Frequency 필드와 GetTimestamp 메서드는 관리되지 않는 Win32 API QueryPerformanceFrequencyQueryPerformanceCounter 대신 사용될 수 있습니다.

Note참고

다중 프로세서 컴퓨터의 경우 스레드가 어떤 프로세서에서 실행되는지는 문제가 되지 않습니다. 그러나 BIOS와 HAL(Hardware Abstraction Layer)의 버그 때문에 프로세서마다 타이밍 결과가 달라질 수 있습니다. 스레드에 대한 프로세서 선호도를 지정하려면 ProcessThread.ProcessorAffinity 메서드를 사용합니다.

다음 예제에서는 Stopwatch 클래스를 사용하여 Windows Form 응용 프로그램의 스톱워치 작업을 구현합니다.

using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
  
namespace StopWatchSample
{    
    public class FormMain : System.Windows.Forms.Form
    {
        private Stopwatch stopWatch;
        private Boolean captureLap;

        public FormMain()
        {
            stopWatch = new Stopwatch();
            captureLap = false;

            InitializeComponent();
        }

        protected override void Dispose( bool disposing )
        {
            base.Dispose( disposing );
        }

        [STAThread]
        static void Main() 
        {
            Application.Run(new FormMain());
        }

        // Define event handlers for various form events.

        private void buttonStartStop_Click(System.Object sender, 
            System.EventArgs e)
        {
            // When the timer is stopped, this button event starts 
            // the timer.  When the timer is running, this button 
            // event stops the timer.
            if (stopWatch.IsRunning)
            {
                // Stop the timer; show the start and reset buttons.
                stopWatch.Stop();
                buttonStartStop.Text = "Start";
                buttonLapReset.Text = "Reset";
            }
            else 
            {
                // Start the timer; show the stop and lap buttons.
                stopWatch.Start();
                buttonStartStop.Text = "Stop";
                buttonLapReset.Text = "Lap";
                labelLap.Visible = false;
                labelLapPrompt.Visible = false;
            }
        }

        private void buttonLapReset_Click(System.Object sender, 
                                     System.EventArgs e)
        {
            // When the timer is stopped, this button event resets
            // the timer.  When the timer is running, this button  
            // event captures a lap time.

            if (buttonLapReset.Text == "Lap")
            {
                if (stopWatch.IsRunning)
                {
                    // Set the object state so that the next
                    // timer tick will display the lap time value.

                    captureLap = true;
                    labelLap.Visible = true;
                    labelLapPrompt.Visible = true;
                }
            }
            else 
            {
                // Reset the stopwatch and the displayed timer value.

                labelLap.Visible = false;
                labelLapPrompt.Visible = false;
                labelTime.Text = "00:00:00.00";
                buttonLapReset.Text = "Lap";
                stopWatch.Reset();
            }        
        }

        private void timerMain_Tick(System.Object sender, 
                                    System.EventArgs e)
        {
            // When the timer is running, update the displayed timer 
            // value for each tick event.

            if (stopWatch.IsRunning)
            {
                // Get the elapsed time as a TimeSpan value.
                TimeSpan ts = stopWatch.Elapsed;

                // Format and display the TimeSpan value.
                labelTime.Text = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", 
                    ts.Hours, ts.Minutes, ts.Seconds, 
                    ts.Milliseconds/10);

                // If the user has just clicked the "Lap" button,
                // then capture the current time for the lap time.

                if (captureLap)
                {
                    labelLap.Text = labelTime.Text;
                    captureLap = false;
                }
            }
        }

        private void labelExit_Click(System.Object sender, 
            System.EventArgs e)
        {
            // Close the form when the user clicks the close button.
            this.Close();
        }

        private void labelTopLeft_Click(object sender, System.EventArgs e)
        {
            this.Location = new Point(0, 0);
        }

        private void labelBottomLeft_Click(object sender, System.EventArgs e)
        {
            this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
        }

        private void labelTopRight_Click(object sender, System.EventArgs e)
        {
            this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, 0);
        }

        private void labelBottomRight_Click(object sender, System.EventArgs e)
        {
            this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, 
                                 Screen.PrimaryScreen.WorkingArea.Height - this.Height);
        }

        private void FormMain_Click(object sender, System.EventArgs e)
        {
            this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, 
                                 (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);
        }

        private void FormMain_Load(object sender, System.EventArgs e)
        {
            // Shape the viewer form with rounded edges.

            DrawForm();
            this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, 
                                 (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);

        }

        private void DrawForm()
        {
            // Shape the viewer form with rounded edges.
            GraphicsPath graphicsPath = new GraphicsPath();

            graphicsPath.AddArc(0, 0, 100, 100, 180, 90);
            graphicsPath.AddArc(100, 0, 100, 100, 270, 90);
            graphicsPath.AddArc(100, 100, 100, 100, 0, 90);
            graphicsPath.AddArc(0, 100, 100, 100, 90, 90);

            this.Region = new Region(graphicsPath);
        }

        // Define various form elements.

        private System.ComponentModel.Container components = null;

        private System.Windows.Forms.Label labelExit;
        private System.Windows.Forms.Label labelTime;
        private System.Windows.Forms.Timer timerMain;
        private System.Windows.Forms.Button buttonLapReset;
        private System.Windows.Forms.Button buttonStartStop;
        private System.Windows.Forms.Label labelLapPrompt;
        private System.Windows.Forms.Label labelTimePrompt;
        private System.Windows.Forms.Label labelLap;
        private System.Windows.Forms.Label labelBottomLeft;
        private System.Windows.Forms.Label labelBottomRight;
        private System.Windows.Forms.Label labelTopLeft;
        private System.Windows.Forms.Label labelTopRight;

        private void InitializeComponent()
        {
            this.SuspendLayout();            

            this.components = new System.ComponentModel.Container();
            this.labelExit = new System.Windows.Forms.Label();
            this.labelTime = new System.Windows.Forms.Label();
            this.buttonLapReset = new System.Windows.Forms.Button();
            this.timerMain = new System.Windows.Forms.Timer(this.components);
            this.labelLap = new System.Windows.Forms.Label();
            this.buttonStartStop = new System.Windows.Forms.Button();
            this.labelLapPrompt = new System.Windows.Forms.Label();
            this.labelTimePrompt = new System.Windows.Forms.Label();
            this.labelBottomLeft = new System.Windows.Forms.Label();
            this.labelBottomRight = new System.Windows.Forms.Label();
            this.labelTopLeft = new System.Windows.Forms.Label();
            this.labelTopRight = new System.Windows.Forms.Label();
        
            // labelExit
        
            this.labelExit.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.labelExit.ForeColor = System.Drawing.Color.Aqua;
            this.labelExit.Location = new System.Drawing.Point(160, 16);
            this.labelExit.Name = "labelExit";
            this.labelExit.Size = new System.Drawing.Size(20, 20);
            this.labelExit.TabIndex = 0;
            this.labelExit.Text = "x";
            this.labelExit.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
            this.labelExit.Click += new System.EventHandler(this.labelExit_Click);            
        
            // labelTime
        
            this.labelTime.Font = new System.Drawing.Font("Comic Sans MS", 18.0F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
            this.labelTime.ForeColor = System.Drawing.Color.Yellow;
            this.labelTime.Location = new System.Drawing.Point(-3, 56);
            this.labelTime.Name = "labelTime";
            this.labelTime.Size = new System.Drawing.Size(208, 32);
            this.labelTime.TabIndex = 1;
            this.labelTime.Text = "00:00:00.00";
        
            // buttonLapReset
        
            this.buttonLapReset.Font = new System.Drawing.Font("Comic Sans MS", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
            this.buttonLapReset.ForeColor = System.Drawing.Color.Yellow;
            this.buttonLapReset.Location = new System.Drawing.Point(104, 160);
            this.buttonLapReset.Name = "buttonLapReset";
            this.buttonLapReset.Size = new System.Drawing.Size(72, 32);
            this.buttonLapReset.TabIndex = 4;
            this.buttonLapReset.Text = "Lap";
            this.buttonLapReset.Click += new System.EventHandler(this.buttonLapReset_Click);            
        
            // timerMain
        
            this.timerMain.Enabled = true;
            this.timerMain.Interval = 50;
            this.timerMain.Tick += new System.EventHandler(this.timerMain_Tick);            
        
            // labelLap
        
            this.labelLap.Font = new System.Drawing.Font("Comic Sans MS", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
            this.labelLap.ForeColor = System.Drawing.Color.Yellow;
            this.labelLap.Location = new System.Drawing.Point(0, 120);
            this.labelLap.Name = "labelLap";
            this.labelLap.Size = new System.Drawing.Size(200, 32);
            this.labelLap.TabIndex = 5;
            this.labelLap.Visible = false;

            // buttonStartStop
        
            this.buttonStartStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.buttonStartStop.Font = new System.Drawing.Font("Comic Sans MS", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
            this.buttonStartStop.ForeColor = System.Drawing.Color.Yellow;
            this.buttonStartStop.Location = new System.Drawing.Point(24, 160);
            this.buttonStartStop.Name = "buttonStartStop";
            this.buttonStartStop.Size = new System.Drawing.Size(72, 32);
            this.buttonStartStop.TabIndex = 2;
            this.buttonStartStop.Text = "Start";
            this.buttonStartStop.Click += new System.EventHandler(this.buttonStartStop_Click);            
        
            // labelLapPrompt
        
            this.labelLapPrompt.Font = new System.Drawing.Font("Comic Sans MS", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
            this.labelLapPrompt.ForeColor = System.Drawing.Color.Yellow;
            this.labelLapPrompt.Location = new System.Drawing.Point(8, 96);
            this.labelLapPrompt.Name = "labelLapPrompt";
            this.labelLapPrompt.Size = new System.Drawing.Size(56, 24);
            this.labelLapPrompt.TabIndex = 6;
            this.labelLapPrompt.Text = "Lap Time";
            this.labelLapPrompt.Visible = false;
        
            // labelTimePrompt
        
            this.labelTimePrompt.Font = new System.Drawing.Font("Comic Sans MS", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
            this.labelTimePrompt.ForeColor = System.Drawing.Color.Yellow;
            this.labelTimePrompt.Location = new System.Drawing.Point(0, 24);
            this.labelTimePrompt.Name = "labelTimePrompt";
            this.labelTimePrompt.Size = new System.Drawing.Size(88, 24);
            this.labelTimePrompt.TabIndex = 7;
            this.labelTimePrompt.Text = "Time";
        
            // labelBottomLeft
        
            this.labelBottomLeft.BackColor = System.Drawing.Color.Black;
            this.labelBottomLeft.ForeColor = System.Drawing.Color.Black;
            this.labelBottomLeft.Location = new System.Drawing.Point(0, 176);
            this.labelBottomLeft.Name = "labelBottomLeft";
            this.labelBottomLeft.Size = new System.Drawing.Size(16, 16);
            this.labelBottomLeft.TabIndex = 8;
            this.labelBottomLeft.Click += new System.EventHandler(this.labelBottomLeft_Click);            
        
            // labelBottomRight
        
            this.labelBottomRight.BackColor = System.Drawing.Color.Black;
            this.labelBottomRight.ForeColor = System.Drawing.Color.Black;
            this.labelBottomRight.Location = new System.Drawing.Point(184, 176);
            this.labelBottomRight.Name = "labelBottomRight";
            this.labelBottomRight.Size = new System.Drawing.Size(16, 16);
            this.labelBottomRight.TabIndex = 9;
            this.labelBottomRight.Click += new System.EventHandler(this.labelBottomRight_Click);            
        
            // labelTopLeft
        
            this.labelTopLeft.BackColor = System.Drawing.Color.Black;
            this.labelTopLeft.ForeColor = System.Drawing.Color.Black;
            this.labelTopLeft.Location = new System.Drawing.Point(0, 8);
            this.labelTopLeft.Name = "labelTopLeft";
            this.labelTopLeft.Size = new System.Drawing.Size(16, 16);
            this.labelTopLeft.TabIndex = 10;
            this.labelTopLeft.Click += new System.EventHandler(this.labelTopLeft_Click);            
        
            // labelTopRight
        
            this.labelTopRight.BackColor = System.Drawing.Color.Black;
            this.labelTopRight.ForeColor = System.Drawing.Color.Black;
            this.labelTopRight.Location = new System.Drawing.Point(184, 8);
            this.labelTopRight.Name = "labelTopRight";
            this.labelTopRight.Size = new System.Drawing.Size(16, 16);
            this.labelTopRight.TabIndex = 11;
            this.labelTopRight.Click += new System.EventHandler(this.labelTopRight_Click);            

        
            // FormMain
           
            this.AutoScaleBaseSize = new System.Drawing.Size(9, 22);
            this.BackColor = System.Drawing.Color.Navy;
            this.ClientSize = new System.Drawing.Size(200, 200);
            this.Controls.Add(this.labelTopRight);
            this.Controls.Add(this.labelTopLeft);
            this.Controls.Add(this.labelBottomRight);
            this.Controls.Add(this.labelBottomLeft);
            this.Controls.Add(this.labelTimePrompt);
            this.Controls.Add(this.labelLapPrompt);
            this.Controls.Add(this.labelLap);
            this.Controls.Add(this.buttonLapReset);
            this.Controls.Add(this.buttonStartStop);
            this.Controls.Add(this.labelTime);
            this.Controls.Add(this.labelExit);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "FormMain";
            this.Text = "StopWatch Sample";
            this.TopMost = true;
            this.Load += new System.EventHandler(this.FormMain_Load);            

            this.ResumeLayout(false);
        }
    }
}

import System.*;
import System.Diagnostics.*;
import System.Windows.Forms.*;
import System.Drawing.*;
import System.Drawing.Drawing2D.*;

public class FormMain extends System.Windows.Forms.Form
{
    private Stopwatch stopWatch;
    private Boolean captureLap;

    public FormMain()
    {
        stopWatch = new Stopwatch();
        captureLap = new Boolean(false);

        InitializeComponent();
    } //FormMain

    protected void Dispose(boolean disposing)
    {
        super.Dispose(disposing);
    } //Dispose

    /** @attribute STAThread()
     */
    public static void main(String[] args)
    {
        Application.Run(new FormMain());
    } //main

    // Define event handlers for various form events.
    private void buttonStartStop_Click(Object sender, System.EventArgs e)
    {
        // When the timer is stopped, this button event starts 
        // the timer.  When the timer is running, this button 
        // event stops the timer.
        if (stopWatch.get_IsRunning()) {
            // Stop the timer; show the start and reset buttons.
            stopWatch.Stop();
            buttonStartStop.set_Text("Start");
            buttonLapReset.set_Text("Reset");
        }
        else {
            // Start the timer; show the stop and lap buttons.
            stopWatch.Start();
            buttonStartStop.set_Text("Stop");
            buttonLapReset.set_Text("Lap");
            labelLap.set_Visible(false);
            labelLapPrompt.set_Visible(false);
        }
    } //buttonStartStop_Click
    
    private void buttonLapReset_Click(Object sender, System.EventArgs e)
    {
        // When the timer is stopped, this button event resets
        // the timer.  When the timer is running, this button  
        // event captures a lap time.
        if (buttonLapReset.get_Text().Equals("Lap")) {
            if (stopWatch.get_IsRunning()) {
                // Set the object state so that the next
                // timer tick will display the lap time value.
                captureLap = new Boolean(true);
                labelLap.set_Visible(true);
                labelLapPrompt.set_Visible(true);
            }
        }
        else {
            // Reset the stopwatch and the displayed timer value.
            labelLap.set_Visible(false);
            labelLapPrompt.set_Visible(false);
            labelTime.set_Text("00:00:00.00");
            buttonLapReset.set_Text("Lap");
            stopWatch.Reset();
        } 
    } //buttonLapReset_Click

    private void timerMain_Tick(Object sender, System.EventArgs e)
    {
        // When the timer is running, update the displayed timer 
        // value for each tick event.
        if (stopWatch.get_IsRunning()) {
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.get_Elapsed();
            // Format and display the TimeSpan value.
            labelTime.set_Text(((System.Int32)ts.get_Hours()).ToString("00") 
                + ":" + ((System.Int32)ts.get_Minutes()).ToString("00") 
                + ":" + ((System.Int32)ts.get_Seconds()).ToString("00") 
                + "." + ((System.Int32)(ts.get_Milliseconds() / 10)).
                ToString("00"));
            // If the user has just clicked the "Lap" button,
            // then capture the current time for the lap time.
            if (System.Convert.ToBoolean(captureLap)) {
                labelLap.set_Text(labelTime.get_Text());
                captureLap = new Boolean(false);
            }
        }
    } //timerMain_Tick

    private void labelExit_Click(Object sender, System.EventArgs e)
    {
        // Close the form when the user clicks the close button.
        this.Close();
    } //labelExit_Click

    private void labelTopLeft_Click(Object sender, System.EventArgs e)
    {
        this.set_Location(new Point(0, 0));
    } //labelTopLeft_Click

    private void labelBottomLeft_Click(Object sender, System.EventArgs e)
    {
        this.set_Location(new Point(0, Screen.get_PrimaryScreen().
            get_WorkingArea().get_Height() - this.get_Height()));
    } //labelBottomLeft_Click

    private void labelTopRight_Click(Object sender, System.EventArgs e)
    {
        this.set_Location(new Point(Screen.get_PrimaryScreen().
            get_WorkingArea().get_Width() - this.get_Width(), 0));
    } //labelTopRight_Click

    private void labelBottomRight_Click(Object sender, System.EventArgs e)
    {
        this.set_Location(new Point(Screen.get_PrimaryScreen().
            get_WorkingArea().get_Width() - this.get_Width(), 
            Screen.get_PrimaryScreen().get_WorkingArea().get_Height() 
            - this.get_Height()));
    } //labelBottomRight_Click

    private void FormMain_Click(Object sender, System.EventArgs e)
    {
        this.set_Location(new Point((Screen.get_PrimaryScreen().
            get_WorkingArea().get_Width() - this.get_Width()) / 2, 
            (Screen.get_PrimaryScreen().get_WorkingArea().get_Height() 
            - this.get_Height()) / 2));
    } //FormMain_Click

    private void FormMain_Load(Object sender, System.EventArgs e)
    {
        // Shape the viewer form with rounded edges.
        DrawForm();
        this.set_Location(new Point((Screen.get_PrimaryScreen().
            get_WorkingArea().get_Width() - this.get_Width()) / 2, 
            (Screen.get_PrimaryScreen().get_WorkingArea().get_Height() 
            - this.get_Height()) / 2));
    } //FormMain_Load

    private void DrawForm()
    {
        // Shape the viewer form with rounded edges.
        GraphicsPath graphicsPath = new GraphicsPath();

        graphicsPath.AddArc(0, 0, 100, 100, 180, 90);
        graphicsPath.AddArc(100, 0, 100, 100, 270, 90);
        graphicsPath.AddArc(100, 100, 100, 100, 0, 90);
        graphicsPath.AddArc(0, 100, 100, 100, 90, 90);

        this.set_Region(new Region(graphicsPath));
    } //DrawForm

    // Define various form elements.
    private System.ComponentModel.Container components = null;
    private System.Windows.Forms.Label labelExit;
    private System.Windows.Forms.Label labelTime;
    private System.Windows.Forms.Timer timerMain;
    private System.Windows.Forms.Button buttonLapReset;
    private System.Windows.Forms.Button buttonStartStop;
    private System.Windows.Forms.Label labelLapPrompt;
    private System.Windows.Forms.Label labelTimePrompt;
    private System.Windows.Forms.Label labelLap;
    private System.Windows.Forms.Label labelBottomLeft;
    private System.Windows.Forms.Label labelBottomRight;
    private System.Windows.Forms.Label labelTopLeft;
    private System.Windows.Forms.Label labelTopRight;

    private void InitializeComponent()
    {
        this.SuspendLayout();

        this.components = new System.ComponentModel.Container();
        this.labelExit = new System.Windows.Forms.Label();
        this.labelTime = new System.Windows.Forms.Label();
        this.buttonLapReset = new System.Windows.Forms.Button();
        this.timerMain = new System.Windows.Forms.Timer(this.components);
        this.labelLap = new System.Windows.Forms.Label();
        this.buttonStartStop = new System.Windows.Forms.Button();
        this.labelLapPrompt = new System.Windows.Forms.Label();
        this.labelTimePrompt = new System.Windows.Forms.Label();
        this.labelBottomLeft = new System.Windows.Forms.Label();
        this.labelBottomRight = new System.Windows.Forms.Label();
        this.labelTopLeft = new System.Windows.Forms.Label();
        this.labelTopRight = new System.Windows.Forms.Label();
        // labelExit
        this.labelExit.set_BorderStyle(
            System.Windows.Forms.BorderStyle.Fixed3D);
        this.labelExit.set_ForeColor(System.Drawing.Color.get_Aqua());
        this.labelExit.set_Location(new System.Drawing.Point(160, 16));
        this.labelExit.set_Name("labelExit");
        this.labelExit.set_Size(new System.Drawing.Size(20, 20));
        this.labelExit.set_TabIndex(0);
        this.labelExit.set_Text("x");
        this.labelExit.set_TextAlign(
            System.Drawing.ContentAlignment.BottomCenter);
        this.labelExit.add_Click(new System.EventHandler(this.labelExit_Click));
        // labelTime
        this.labelTime.set_Font(new System.Drawing.Font("Comic Sans MS", 18, 
            System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point));
        this.labelTime.set_ForeColor(System.Drawing.Color.get_Yellow());
        this.labelTime.set_Location(new System.Drawing.Point(-3, 56));
        this.labelTime.set_Name("labelTime");
        this.labelTime.set_Size(new System.Drawing.Size(208, 32));
        this.labelTime.set_TabIndex(1);
        this.labelTime.set_Text("00:00:00.00");
        // buttonLapReset
        this.buttonLapReset.set_Font(new System.Drawing.Font("Comic Sans MS", 
            14.25f, System.Drawing.FontStyle.Bold, 
            System.Drawing.GraphicsUnit.Point));
        this.buttonLapReset.set_ForeColor(System.Drawing.Color.get_Yellow());
        this.buttonLapReset.set_Location(new System.Drawing.Point(104, 160));
        this.buttonLapReset.set_Name("buttonLapReset");
        this.buttonLapReset.set_Size(new System.Drawing.Size(72, 32));
        this.buttonLapReset.set_TabIndex(4);
        this.buttonLapReset.set_Text("Lap");
        this.buttonLapReset.add_Click(new System.EventHandler(
            this.buttonLapReset_Click));
        // timerMain
        this.timerMain.set_Enabled(true);
        this.timerMain.set_Interval(50);
        this.timerMain.add_Tick(new System.EventHandler(this.timerMain_Tick));
        // labelLap
        this.labelLap.set_Font(new System.Drawing.Font("Comic Sans MS", 
            (float)14.25, System.Drawing.FontStyle.Regular, 
            System.Drawing.GraphicsUnit.Point));
        this.labelLap.set_ForeColor(System.Drawing.Color.get_Yellow());
        this.labelLap.set_Location(new System.Drawing.Point(0, 120));
        this.labelLap.set_Name("labelLap");
        this.labelLap.set_Size(new System.Drawing.Size(200, 32));
        this.labelLap.set_TabIndex(5);
        this.labelLap.set_Visible(false);
        // buttonStartStop
        this.buttonStartStop.set_FlatStyle(System.Windows.Forms.FlatStyle.Flat);
        this.buttonStartStop.set_Font(new System.Drawing.Font("Comic Sans MS",
            (float)14.25, System.Drawing.FontStyle.Bold, 
            System.Drawing.GraphicsUnit.Point));
        this.buttonStartStop.set_ForeColor(System.Drawing.Color.get_Yellow());
        this.buttonStartStop.set_Location(new System.Drawing.Point(24, 160));
        this.buttonStartStop.set_Name("buttonStartStop");
        this.buttonStartStop.set_Size(new System.Drawing.Size(72, 32));
        this.buttonStartStop.set_TabIndex(2);
        this.buttonStartStop.set_Text("Start");
        this.buttonStartStop.add_Click(new System.EventHandler(
            this.buttonStartStop_Click));
        // labelLapPrompt
        this.labelLapPrompt.set_Font(new System.Drawing.Font("Comic Sans MS", 
            (float)14.25, System.Drawing.FontStyle.Regular, 
            System.Drawing.GraphicsUnit.Point));
        this.labelLapPrompt.set_ForeColor(System.Drawing.Color.get_Yellow());
        this.labelLapPrompt.set_Location(new System.Drawing.Point(8, 96));
        this.labelLapPrompt.set_Name("labelLapPrompt");
        this.labelLapPrompt.set_Size(new System.Drawing.Size(56, 24));
        this.labelLapPrompt.set_TabIndex(6);
        this.labelLapPrompt.set_Text("Lap Time");
        this.labelLapPrompt.set_Visible(false);
        // labelTimePrompt
        this.labelTimePrompt.set_Font(new System.Drawing.Font("Comic Sans MS", 
            (float)15.75, System.Drawing.FontStyle.Regular, 
            System.Drawing.GraphicsUnit.Point));
        this.labelTimePrompt.set_ForeColor(System.Drawing.Color.get_Yellow());
        this.labelTimePrompt.set_Location(new System.Drawing.Point(0, 24));
        this.labelTimePrompt.set_Name("labelTimePrompt");
        this.labelTimePrompt.set_Size(new System.Drawing.Size(88, 24));
        this.labelTimePrompt.set_TabIndex(7);
        this.labelTimePrompt.set_Text("Time");
        // labelBottomLeft
        this.labelBottomLeft.set_BackColor(System.Drawing.Color.get_Black());
        this.labelBottomLeft.set_ForeColor(System.Drawing.Color.get_Black());
        this.labelBottomLeft.set_Location(new System.Drawing.Point(0, 176));
        this.labelBottomLeft.set_Name("labelBottomLeft");
        this.labelBottomLeft.set_Size(new System.Drawing.Size(16, 16));
        this.labelBottomLeft.set_TabIndex(8);
        this.labelBottomLeft.add_Click(new System.EventHandler(
            this.labelBottomLeft_Click));
        // labelBottomRight
        this.labelBottomRight.set_BackColor(System.Drawing.Color.get_Black());
        this.labelBottomRight.set_ForeColor(System.Drawing.Color.get_Black());
        this.labelBottomRight.set_Location(new System.Drawing.Point(184, 176));
        this.labelBottomRight.set_Name("labelBottomRight");
        this.labelBottomRight.set_Size(new System.Drawing.Size(16, 16));
        this.labelBottomRight.set_TabIndex(9);
        this.labelBottomRight.add_Click(new System.EventHandler(
            this.labelBottomRight_Click));
        // labelTopLeft
        this.labelTopLeft.set_BackColor(System.Drawing.Color.get_Black());
        this.labelTopLeft.set_ForeColor(System.Drawing.Color.get_Black());
        this.labelTopLeft.set_Location(new System.Drawing.Point(0, 8));
        this.labelTopLeft.set_Name("labelTopLeft");
        this.labelTopLeft.set_Size(new System.Drawing.Size(16, 16));
        this.labelTopLeft.set_TabIndex(10);
        this.labelTopLeft.add_Click(new System.EventHandler(
            this.labelTopLeft_Click));
        // labelTopRight
        this.labelTopRight.set_BackColor(System.Drawing.Color.get_Black());
        this.labelTopRight.set_ForeColor(System.Drawing.Color.get_Black());
        this.labelTopRight.set_Location(new System.Drawing.Point(184, 8));
        this.labelTopRight.set_Name("labelTopRight");
        this.labelTopRight.set_Size(new System.Drawing.Size(16, 16));
        this.labelTopRight.set_TabIndex(11);
        this.labelTopRight.add_Click(new System.EventHandler(
            this.labelTopRight_Click));
        // FormMain
        this.set_AutoScaleBaseSize(new System.Drawing.Size(9, 22));
        this.set_BackColor(System.Drawing.Color.get_Navy());
        this.set_ClientSize(new System.Drawing.Size(200, 200));
        this.get_Controls().Add(this.labelTopRight);
        this.get_Controls().Add(this.labelTopLeft);
        this.get_Controls().Add(this.labelBottomRight);
        this.get_Controls().Add(this.labelBottomLeft);
        this.get_Controls().Add(this.labelTimePrompt);
        this.get_Controls().Add(this.labelLapPrompt);
        this.get_Controls().Add(this.labelLap);
        this.get_Controls().Add(this.buttonLapReset);
        this.get_Controls().Add(this.buttonStartStop);
        this.get_Controls().Add(this.labelTime);
        this.get_Controls().Add(this.labelExit);
        this.set_Font(new System.Drawing.Font("Microsoft Sans Serif", 
            (float)14.25, System.Drawing.FontStyle.Regular, 
            System.Drawing.GraphicsUnit.Point));
        this.set_FormBorderStyle(System.Windows.Forms.FormBorderStyle.None);
        this.set_Name("FormMain");
        this.set_Text("StopWatch Sample");
        this.set_TopMost(true);
        this.add_Load(new System.EventHandler(this.FormMain_Load));

        this.ResumeLayout(false);
    } //InitializeComponent
} //FormMain

System.Object
  System.Diagnostics.Stopwatch

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

.NET Framework

2.0에서 지원

커뮤니티 추가 항목

추가
표시:
© 2015 Microsoft