我有一個顯示大量圖像或按鈕之一的頁面。點擊按鈕後,我將其隱藏並顯示列表中的下一個圖像。點擊圖像使其消失並再次顯示該按鈕。快速連續檢測點擊事件
當連續多次單擊按鈕時,顯示的圖像不會響應被點擊。我想這是由於UI線程阻塞,但我嘗試與工作線程,並仍然無法正常工作。
public void ShowNextImage()
{
image_new.Source = getCurrentBitmap();
workerThread.WorkerReportsProgress = true;
workerThread.WorkerSupportsCancellation = true;
workerThread.DoWork += new DoWorkEventHandler(worker_DoWork);
workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
workerThread.RunWorkerAsync();
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
transition.Begin();
transition.Completed += delegate
{
transition.Stop();
};
});
}
void worker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
// Happens on the UI thread so its ok
MessageBox.Show("Error occurred...");
}
}
你可以改善這個標題所以它的問題? – Stuart 2011-05-12 10:43:50
你在圖像上訂閱了哪些事件? – 2011-05-12 10:45:41
你可以請示出一些代碼,它演示你正在做什麼,並允許我們重新創建問題。 – 2011-05-12 10:58:57