Windows 8 series (6): backgroundtask and crash that cannot be captured

Source: Internet
Author: User

Today I want to share with you about backgroundtask. Before that, let's take a look at this problem: crash that cannot be captured by vs2011 (crash ).

After a certain version of Alpha is released, the tester reported that our application is not as stable as the previous version, and will always be automatically disabled or restarted, and the operation steps are irregular, low Probability of appearance.

My first response was: system problems. This is because similar problems are also encountered during self-testing. For example, when debugging a function (usually takes about 5 minutes or longer), the applicationProgramAnd vs Automatically releases the debug status. This makes me wonder, if an exception occurs, it should be thrown to the developer in the debug state. How can I disable the debug state for no reason ??

Until we reached the deadline for official application submission, this problem was infinitely magnified and became the most difficult problem we had to solve at that time. If no log or exception is thrown, we can only try every path to the answer.

 

Later, we found that when we started the program and did not do anything, we still had crash, and the crash time was not fixed, which was about 5-15 minutes. I recalled that at that time, only the global timer was running, but when we removed the timer, the crash still exists.

 

So we thought of the background. Is it true that the background is also executed when the program is running ?? The official document describes

If a background task executes within the app process, the background task infrastructure might need to change the state of the APP:

· Running: If the app is running, it is already in the foreground and the background task is simply launched within the app.

· Sushortded: If the app is sushortded, most of its threads are unfrozen and the background task is launched. for details, see "threading model for background tasks hosted in the app," later in this paper.

· Terminated: If the app is terminated, it is not running at the time of the trigger so the app is launched and the background task is run. the app activation does not involve UI, and it does not bring the app to the foreground.

 

That is to say, backgroundtask is also running when the program is running. But ourCodeIt is written based on the code in the officially provided sample. The settings are the same and should not be wrong. After our tests, crash may also occur in the official sample... The reason is that our development environment has been upgraded to an internal version with some code changes, but the official documentation does not mention the relevant changes and related methods, this affects the normal development progress to some extent. (But I would like to thank Microsoft China for its support and help us respond to the situation at the headquarters)

 

For example, because our backgroundtask is triggered every 15 minutes, we add backgroundtasks to the declarations tab of the configuration file, and then select only timer in the settings on the right, the content of the switch executable item must be blank (multiple options are selected in the official sample, and the content of the executable item is backgroundtaskhost.exe)

 

Then try again. The crash phenomenon is gone, and the backgroundtask can also run normally. Our efforts are not in vain. We hope to help developers who encounter problems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.