VS2012 (및 이전 버전에서도 마찬가지 임)는 "주 스레드"또는 중단 점에 도달 한 스레드를 사용하여 속성의 getter를 실행합니다. 나는 두 개의 브레이크 포인트를 설정
static class TestSideEffects
{
public static void Test()
{
Console.WriteLine("Main Thread: {0}", Thread.CurrentThread.ManagedThreadId);
var o = new TestSubject();
Console.WriteLine("Property Value: {0}", o.IntGetValueNoSe());
}
}
class TestSubject
{
private int _prop=0;
public int TheProperty
{
get
{
Console.WriteLine("Thread accessing the property: {0}", Thread.CurrentThread.ManagedThreadId);
return ++_prop;
}
}
public int IntGetValueNoSe(){return _prop; }
}
:
이
내 테스트 코드 자체 시험 방법의 세번째 줄에와 게터에, 나는이 O 인스턴스 위에서 내 마우스를 가져 때마다 - 그것은 실행 getter는 다른 중단 점을 트리거하지 않습니다. 동일한 (이 경우 메인) 스레드를 사용합니다. 얼마 전에
Main Thread: 8
Thread accessing the property: 8
Thread accessing the property: 8
Thread accessing the property: 8
내가 그것에 기사를 통해 오는 기억하는 것,하지만 내 Google - Fu는 다시 그것을 찾기 위해 너무 약합니다 :
이
은 테스트 프로그램의 출력입니다. – Smashery[부작용 및 표현식]을 시작하려면 (http://msdn.microsoft.com/en-us/library/a7a250bs.aspx) – horgh