Windows phone 在windows phone中操纵滑块时提高软件响应能力
我的windows phone 7.1项目中有一个滑块。操纵时,此滑块将触发一个事件,该事件启动后台工作程序以执行多个三角运算 如果我将光标移动到滑块上,则响应会有一定的延迟。尽管我在操纵启动事件中实现了后台工作程序cancelAsync方法,但我希望获得更高的响应速度,如何实现这一点 代码:Windows phone 在windows phone中操纵滑块时提高软件响应能力,windows-phone,Windows Phone,我的windows phone 7.1项目中有一个滑块。操纵时,此滑块将触发一个事件,该事件启动后台工作程序以执行多个三角运算 如果我将光标移动到滑块上,则响应会有一定的延迟。尽管我在操纵启动事件中实现了后台工作程序cancelAsync方法,但我希望获得更高的响应速度,如何实现这一点 代码: 听起来您的代码可能没有完全优化-请发布您的代码,以便我们可以看到: private void sliderCosinus_ManipulationStarted(object sender,Mani
听起来您的代码可能没有完全优化-请发布您的代码,以便我们可以看到:
private void sliderCosinus_ManipulationStarted(object sender,ManipulationStartedEventArgs e)
{
if (bw.WorkerSupportsCancellation == true)
{
bw.CancelAsync(); // Cancel the asynchronous operation.
}
}
private void sldCosinus_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
try
{
Value = Convert.ToInt32(sldCosinus.Value) * 10;
}
catch
{
// errore message here
}
finally
{
}
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
if ((worker.CancellationPending == true))
{
e.Cancel = true;
}
else
{
Dispatcher.BeginInvoke(() => app.IsEffectApplied=TrigonometricTrans()
// TrigonomtriecTrans calculate sin and cosinus for every pixel in image
}
}
private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
// progress bar here
}
private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if ((e.Cancelled == true))
{
//this.tbProgress.Text = "Canceled!";
}
else if (!(e.Error == null))
{
//this.tbProgress.Text = ("Error: " + e.Error.Message);
}
else
{
DoubleBufferToScreen();
}
}