公共静态异步任务<;字符串>;VerticalScrollingTest(){…//初始化double allFramesTime=0;int FrameScont=0;for(int z=0;z<;20;z++){for(int i=0;i<;10;i++){var s=Stopwatch.StartNew();grid.ScrollDown(80);Wait CompositionTargetHelper.WaitRendering();s.Stop(); allFramesTime+=s.已过。总秒数;FrameScont++;}对于(int i=0;i<;10;i++){var s=Stopwatch.StartNew();grid.ScrollUp(80);wait CompositionTargetHelper.WaitRendering();s.Stop();allFramesTime+=s.persed.TotalSeconds;FrameScont++;}返回$";Fps{FrameScont/allFramesTime}";}类CompositionTargetHelper{static CompositionTargetHelper(){CompositionTarget.Rendering+=OnRendering;}public static Task WaitRendering(){return Task?.Task???(Task=new TaskCompletionSource()).Task;}静态任务完成源任务;静态void OnRendering(object sender,object e){var t=task;task=null;t?.SetResult();}