分类: 嵌入式
2011-01-29 12:37:36
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.
AO的最常见用法:
SomeAsyncFunc(iStatus); // 提交请求
SetActive(); // 把自己设为活动状态