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 for Bug 51421 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
I think this may be a Xamarin bug. The repro test project is at https://github.com/lauxjpn/ExitTest02
I might be a bad interaction between Mono and Dalvik/Art/Java, I'll investigate. But, in general, it's better to call Activity.Finish() in the launcher activity to quit the Android app - much safer.
I can confirm this behaviour. Repeating the reproduction steps here:
1. Open the attached project in Visual Studio for Mac
2. Set a break point in the Android project in the `SomeActivity.OnBackPressed` method.
3. Run the application
4. Click the "Disable" button
5. Click on the system back button
6. The app will hang.
All this said, it would be more appropriate to call `Activity.Finish()` than to call `System.Environment.Exit()`
Created attachment 23116 [details]
Sample project duplicating the bug.
Why is `Environment.Exit()` being called in the first place? Normally the Android process should not be exited by user code; Android will kill the process when necessary.
No idea why the user is doing this. It was originally a bug filed with MvvmCross and I punted it here.
I am running into this issue. It is holding up our unit test automation. The have a usecase for calling Environment.Exit(). After unit tests are run and test run is complete, I want to exit the app/process. I have a batch script that looks for running process via package name. As soon as the pid becomes empty, I want to fetch the unit test results file from sdcard to local disk.
So in my app I called System.Enviornment.Exit(1); This causes the app to hang. which leaves the process running forever. Jenkins job never finishes because pid is not empty.
I would really appreciate any workaround or insight on how can I achieve this.
Basically I want my app to terminate after test run is complete and the app knows when tests runs are complete. I want to exit right after that.