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.
Steps to Reproduce:
1- Open the app in a Emulator or Device. In the OnCreate method I launch the Task or Thread.
2- You can Navigate to other activitys, and go back to the Main Activity and the Task or Thread are not launching again.
3- When you are in the Main activity click the back button of the Emulator or Device:
4- The application goes to background and the Task or Thread continues running which its fine, that's what I want.
5- Now from your Emulator or Device open again the application.
6- Now you can see the Task or Thread launch twice, and if you repeat the steps it will launching more.
How can I detect a running one to not launching again. Because this line don’t work if (_task == null)
When the app goes to background and you open it again _task is always null.
Created attachment 2975 [details]
The Test Case for the issue
> 6- Now you can see the Task or Thread launch twice
What does this mean? Is there more than one Tasky process running (`adb shell ps | grep Tasky`)? Is Activity.OnCreate() re-executed (I'd expect this behavior)?
> How can I detect a running one to not launching again. Because this line don’t
> work if (_task == null)
> When the app goes to background and you open it again _task is always null.
This is expected and By Design:
Activity1._task is an instance member. Consequently, its value is tied to the lifetime of the Activity instance.
The Activity instance's lifetime is in turn managed by Android, and when you tap the Back button the Activity instance is _destroyed_:
If you need to have state that is tied to the process, it must not be a member of an Activity. It should either be part of an Android.App.Application, or it should be hosted by a Android.App.Service or other type. Activities are constantly created and destroyed for a variety of reasons; app-global state SHOULD NOT be solely referenced by Activities.