2010-03-09 4 views
2

사용자 지정 애니메이션을 사용하여 Silverlight 응용 프로그램을 개발하고 있습니다. 변수 animationCounter를 1 밀리 초마다 업데이트하여 1 초에 값이 1000이되도록하고 싶습니다. DispatcherTimer 및 System.Threading.Timer를 시도했습니다. 이 방법 :Silverlight 타이머 문제

DispatcherTimer timer = new DispatcherTimer(); (...) 
timer.Interval = new TimeSpan(0, 0, 0, 0, 1); 
timer.Tick += new EventHandler(timer_Tick); (...) 

(...)이 System.Threading.Timer

System.Threading timer = null; 
timer = new System.Threading.Timer(UpdateAnimationCounter, 0, 1); 

void UpdateAnimationCounter(object state) 
{ 
       animationCounter++; 
     Dispatcher.BeginInvoke(() => txtAnimationCounter.Text = animationCounter.ToString()); 
} 

둘 다 1 초에 약 100 AnimationCounter를 설정하는과

void timer_Tick(object sender, EventArgs e) 
{ 
     animationCounter++; 
     Dispatcher.BeginInvoke(() => txtAnimationCounter.Text = animationCounter.ToString()); 
} 

. 1000이어야합니다. 왜 그런지 모르겠습니다. 내가 빠진 것이 있니?

감사

답변

3

문서는 타이머가이 1ms의 해상도를 가지고 있지 않음을 명시해야하지만, 10ms의 최소의)는에 더 tseem하지 않습니다. 어쨌든, 최소한의 타이머 해상도는 약 10ms ... 그래서 그들이 발사하는 가장 작은 간격입니다.

어째서 1ms가 필요합니까? 나에게 쓸모없는 소리. 애니메이션은 초당 약 25 - 60 건의 업데이트로 괜찮습니다. 나머지는 눈으로 볼 수 없습니다.

+0

또한 10ms 해상도를 나타내는 문서는 발견되지 않았지만 다른 사이트에서는 힌트를 표시했습니다. –

+0

감사합니다. 나는 그것을 몰랐다. 네, 10ms 해상도가 괜찮을 것 같습니다. 동기화시 일부 애니메이션 이벤트를 시작하려면이 값이 필요합니다. – jose