Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
attempting to access any UI objects from Main Activity from a BackgroundWorker RunWorkerCompleted event causes an unknown exception. Without accessing UI objects , no exception is thrown. This leads me to believe RunWorkerCompleted is not executed within the UI thread.
public class MainActivity : Activity
private ProgressDialog progressDialog;
protected override void OnCreate(Bundle bundle)
Button searchButton = FindViewById<Button>(Resource.Id.SubmitButton);
searchButton.Click += new EventHandler(searchButton_Click);
void searchButton_Click(object sender, EventArgs e)
this.progressDialog = ProgressDialog.Show(this, "Search", "Please Wait...");
// find information
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
//******** CRASH BELOW ***********//
void worker_DoWork(object sender, DoWorkEventArgs e)
// do stuff
The problem is that we haven't done any integration between .NET's SynchronizationContext and Android's main thread.
We need to make System.Threading.SynchronizationContext.Current, in effect, return the Android.App.Application.SynchronizationContext instance:
That will allow (in this case) AsyncOperationManager.SynchronizationContext calls to be invoked on the UI thread, as expected.
Fixed in commit 45ea51bc.