Exiting a program which is waiting on a request
Article Metadata
Many a times it happens that a user terminates a program which has actually sent a request for a service. Ideally if an Exit command is fired the pending request should be cancelled and then the program should be terminated. But in some cases the pending request takes a considerable amount of time to be cancelled. For e.g. a Bluetooth discovery request
void CDeviceDiscoverer::DiscoverDevicesL(TDeviceDataList* aDevDataList)
{
iDiscoveredDeviceCount=0;
// wipe existing device data list, start fresh
iDevDataList=aDevDataList;
iDevDataList->Reset();
// load protocol for discovery
TProtocolDesc pdesc;
User::LeaveIfError(iSocketServ.FindProtocol(KBTLinkManagerTxt(), pdesc));
// initialize host resolver
User::LeaveIfError(iResolver.Open(iSocketServ, pdesc.iAddrFamily,
pdesc.iProtocol));
// start device discovery by invoking remote address lookup
iAddr.SetIAC(KGIAC);
iAddr.SetAction(KHostResInquiry|KHostResName|KHostResIgnoreCache);
iResolver.GetByAddress(iAddr, iEntry, iStatus);
SetActive();
}
does not end fast with a call to Cancel().
In such one option is to show a wait note.
Other workaround is to send the application to the background and exit once the request has been canceled or the request is completed.


(no comments yet)