어디에 문제가 있습니까?VolatileWrite 불리언
bool stillSingleClick = false;
// does not compime
System.Threading.Thread.VolatileWrite(ref stillSingleClick, true);
는
'System.Threading.Thread.VolatileWrite (REF 개체, 개체)'에 가장 적합한 오버로드 된 메서드 일치
왜 물어 않는 일부 무효 인수가 .. I 다음과 같은 방법으로 내에서 doubleClick을 차별화하려고 :
volatile bool stillSingleClick = false;
void SegmentLine_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
SegmentLine line = sender as SegmentLine;
if (e.ClickCount == 1)
{
stillSingleClick = true;
Thread thread = new Thread(
new System.Threading.ThreadStart(
delegate()
{
line.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
Thread.Sleep(System.Windows.Forms.SystemInformation.DoubleClickTime * 2);
if (stillSingleClick) // HERE ALWAYS TRUE!!!
{
SelectSegmentLine(line);
}
stillSingleClick = false;
}
));
}
));
thread.Start();
}
else if (e.ClickCount == 2)
{
stillSingleClick = false; // HERE SHOULD BE SET IN FALSE !!!
DisplaySegmentLineInfo(line);
}
}
가을 작동하지 않습니다은 항상 참입니다 ...
휘발성 필드로 업데이트 설명 – serhio
+1 @cdhowie 예 int를 사용하는 것은 잘못되었지만 때때로 정확하게 동일한 작업을 수행해야합니다. True와 False에 대한 const가 있어야 할 때 잘못된 생각을하는 경우 : –
그래서 Jon이 제안한 것처럼 휘발성 논리 연산을 사용하지 않은 이유는 무엇입니까? – serhio