WP7录音时遇到".Update has not been called. Regular FrameworkDispatcher.Update calls are necessary for fire and forget sound effects and framework events to function correctly. ",找了资料是这么说的:
如果您从一个应用程序使用XNA框架,不执行游戏类,例如,一个Windows Phone应用程序中使用Silverlight应用程序的模型,你必须在XNA框架消息队列中调用自己的FrameworkDispatcher.Update方法发送消息。你可以做到这一点,在一个定时器每帧循环一次,或者你可以实现一个DispatcherTimer Tick事件处理程序IApplicationService接口。
方法1:调用xna类前加
DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(33); timer.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } }; timer.Start();
2:
public class XnaAsyncDispatcher : IApplicationService
{
private readonly DispatcherTimer _frameworkDispatcherTimer;
public XnaAsyncDispatcher(TimeSpan dispatchInterval)
{
FrameworkDispatcher.Update();
_frameworkDispatcherTimer = new DispatcherTimer();
_frameworkDispatcherTimer.Tick += FrameworkDispatcherTimer_Tick;
_frameworkDispatcherTimer.Interval = dispatchInterval;
}
void IApplicationService.StartService(ApplicationServiceContext context)
{
_frameworkDispatcherTimer.Start();
}
void IApplicationService.StopService()
{
_frameworkDispatcherTimer.Stop();
}
private static void FrameworkDispatcherTimer_Tick(object sender, EventArgs e)
{
FrameworkDispatcher.Update();
}
}