I'm trying to show a waiting message via a Toast while a long operation is running. I'm using a BackgroundWorker. This code is inside a ListView_ItemClick event handler:
var bgWait = new BackgroundWorker();
bgWait.DoWork += bgWait_DoWork;
bgWait.RunWorkerAsync();
bgWait.RunWorkerCompleted += bgWait_Completed;
The code in bgWait_DoWork event handler is the following:
private void bgWait_DoWork(object sender, DoWorkEventArgs e)
{
var toastWait = Toast.MakeText(this, "Please wait", ToastLength.Long);
toastWait.SetGravity(GravityFlags.Top & GravityFlags.Center, 0, 0);
toastWait.Show();
TimeConsumingOperation();
toastWait.Cancel();
}
When I run in debug mode, it seems that only the first line from bgWait_DoWork is reached - "var toastWait = Toast.MakeText(this, "Please wait", ToastLength.Long);" - and then it jumps to bgWait_Completed event handler.
Any idea why this is happening?
Thanks