Please don't think it's a redundant question. Please read completely.
I have an infinite loop inside the doInBackground(Void... params) of AsyncTask. And there's a callback function within doInBackground(). So, I am not able to terminate this task using cancel(), onCancelled() and isCancelled() approach. The problem is the execution waits at the callback function forever. So, no matter where (within doInBackground) I write this isCancelled() check to break out of the infinite loop, it doesnt get executed.
Does anyone have a solution for this kind of problem? Or anyone had a requirement similar to this?
@Override
protected void onCancelled()
{
// Socket Close
}
@Override
protected Void doInBackground(Void... params)
{
try
{
// Socket Open
while (true)
{
socket.receive();
}
}
catch (Exception e)
{
}
return null;
}