A stray-event panic from the Active Scheduler ( E32USER-CBASE 46 error ) is a most common problem with an Active Objects. This is ussually caused by one ( or more ) of the following:
1. You forgot to call CActiveScheduler::Add() before starting the Active Object.
2. You dont call SetActive() after issuing an async request.
3. Passing the same iStatus to two service providers at the same time ( multiple requests outstanding on the same Active Object ).
Do not invoke DoCancel() directly - it should be private - always call Cancel(). Note that Cancel() should be always be called in the destructor of your derived class.
Other related pitfalls (triggering other panics)
4. Using your own TRequestStatus variable, instead of using the one provided by CActive.
5. Passing automatic variables when doing an asynchronous request.
一、E32User-CBase 46 Panic 的成因
- 忘记将 CActive 对加入 CActiveScheduler;
- 在发起异步请求之后忘记调用 SetActive();
- 同时有两个或以上的请求使用同一个 iStatus;
- 没有使用 CActive 的 iStatus 成员,而是使用了 TRequestStatus 变量;
- 在异步请求中发送了自动变量.
AO的最常见用法:
SomeAsyncFunc(iStatus); // 提交请求
SetActive(); // 把自己设为活动状态