C#, .NET
Window Message 를 직접 처리하기
휘사마
2011. 6. 17. 19:37
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace Sorting
{
public partial class TimeMeasurement : Form
{
public TimeMeasurement()
{
InitializeComponent();
}
private IntPtr start = new IntPtr(0);
private IntPtr end = new IntPtr(1);
private int WM_USER = 0x400;
private Stopwatch sw = new Stopwatch();
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_USER + 1)
{
if (m.WParam == start)
{
Debug.WriteLine(m.ToString());
Debug.WriteLine("시간측정 시작("+DateTime.Now+")");
sw.Reset();
sw.Start();
}
else if (m.WParam == end)
{
sw.Stop();
Debug.WriteLine("경과 시간(StopWatch) = " + sw.ElapsedTicks + " ticks(" + sw.Elapsed + " 초)");
Debug.WriteLine("시간측정 종료(" + DateTime.Now + ")\n");
}
}
}
}
}