2
예를 들어, Parallel.For를 사용하여 더 좋은 성능을 보일 수 있도록이 변환 방법이 있는지 궁금합니다.이 WPF 코드는 Parallel.For의 이점을 얻을 수 있습니까?
public FrameworkElement FindIntersectingElement(Rect rectangle, UIElement activeElement)
{
foreach (var child in this.Children)
{
if (child != activeElement)
{
if (GetBounds(child as FrameworkElement, this).IntersectsWith(rectangle))
{
return child as FrameworkElement;
}
}
}
return null;
}
public Rect GetBounds(FrameworkElement of, FrameworkElement from)
{
GeneralTransform transform = null;
transform = of.TransformToVisual(from);
return transform.TransformBounds(new Rect(0, 0, of.ActualWidth, of.ActualHeight));
}
의견이 있으십니까?
고맙습니다. 그리고 많은 수의 요소를 가지고 나는 실제로 속도 향상 (8 코어 머신에서 테스트)을 보았습니다. 단일 코어에 대한 선호도를 제한하면 differenc e도 마찬가지입니다. – TimothyP
UIElementCollection이 제네릭 형식이 아니기 때문에 캐스트 (IEnumerable)가 작동한다고 생각하지 않습니다. –
@Chris, Timothy는 이미 그것이 효과가 있다고보고했습니다. –