Value of Application Context Variables Lost on Application Error

前端 未结 1 467
半阙折子戏
半阙折子戏 2021-01-15 14:32

I noticed that when my application encounters an error, the value of my application context variables are also reinitialized to its original value (not the updated value). B

相关标签:
1条回答
  • 2021-01-15 15:18

    How can I save and restore the values of my application context variables when an application error occurs?

    First, don't have an unhandled exception.

    Second, don't rely on static data members or custom Application subclass instances. There are many scenarios in which your process will be terminated and those values go away. They should be used for an in-memory cache of persistent content, and little else.

    Sometimes, unhandled exceptions are truly unexpected, but these should be infrequent and usually tied to specific devices (e.g., ran out of storage space). Everything else represents a bug in your app, and you must fix the bugs.

    0 讨论(0)
提交回复
热议问题