You seem to be going through a lot of complicated tricks with operations, blocks, completion blocks, queues, and other stuff, for no apparent reason. AFAICT, you've got all that stuff linked together in barely comprehensible ways, and the end purpose is simply to force sequential execution.
So why not eliminate all that complexity and just do plain sequential execution.
Write one method that contains the following:
Since sequential execution is what happens by default when you put one line of code after another, that's what I've done: put one line of code after another.
You then execute this one method on a background thread. There are any number of ways of doing this, but one of the simplest is performSelectorInBackground:withObject: from NSObject.
http://developer.apple.com/library/...asses/NSObject_Class/Reference/Reference.html
The one method then runs to completion on the background thread. And while it's in the background thread, the lines of code in the one method simply run sequentially.
The saysOnMainThread: method just calls performSelectorOnMainThread with the string given, and a selector of printToScreen:. It doesn't even have to wait, because whenever the main thread gets around to updating the display, or whether it does or doesn't, it simply doesn't matter to the background thread. It's fulfilled its task just by delivering the text. It can then get on with its next sequential line of code.
And I again want to emphasize: everything that's happening is sequential. Loading a file, making a dictionary, getting symbols, doing something with Parameters, making an upload request, etc. is all done in sequence on a single background thread. You can sprinkle any number of "tell the main thread to display X" actions in the mix, and it's still sequential. You don't even have to wait for the main thread at any point, because waiting or not waiting has no bearing at all on the next sequential action.
At some point after you've got the plain ordinary sequential actions working, then you can look at how to cancel background tasks. But until the plain sequential stuff works, trying to deal with cancelling is pointless.
As to why uploadDataRequest is failing, there's no way to tell. It's impossible to discern what you're expecting to happen. One red flag I see is the complete lack of error handling, or even error checks. You've also got a class URLRequest whose operation is utterly opaque since you've shown no code for it.
So why not eliminate all that complexity and just do plain sequential execution.
Write one method that contains the following:
Code:
NSString* filespace=[[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding];
// Are you sure ASCII, a 7-bit code, is the proper encoding?
// Are you sure it can't possibly error out?
virtual_machine_32 *vm = [[virtual_machine_32 alloc]init];
[self saysOnMainThread:@" Parsing Executable...\n"];
[vm loadelf:filespace];
Parameters *send=[[Parameters alloc]init];
// Just get the NSDictionary and set the Parameters symbols here.
// Don't put it in an operation.
[self saysOnMainThread:@" Executing...\n"];
[vm vm32:send];
[self uploadDataRequest];
// clean up with correct releases etc.
You then execute this one method on a background thread. There are any number of ways of doing this, but one of the simplest is performSelectorInBackground:withObject: from NSObject.
http://developer.apple.com/library/...asses/NSObject_Class/Reference/Reference.html
The one method then runs to completion on the background thread. And while it's in the background thread, the lines of code in the one method simply run sequentially.
The saysOnMainThread: method just calls performSelectorOnMainThread with the string given, and a selector of printToScreen:. It doesn't even have to wait, because whenever the main thread gets around to updating the display, or whether it does or doesn't, it simply doesn't matter to the background thread. It's fulfilled its task just by delivering the text. It can then get on with its next sequential line of code.
And I again want to emphasize: everything that's happening is sequential. Loading a file, making a dictionary, getting symbols, doing something with Parameters, making an upload request, etc. is all done in sequence on a single background thread. You can sprinkle any number of "tell the main thread to display X" actions in the mix, and it's still sequential. You don't even have to wait for the main thread at any point, because waiting or not waiting has no bearing at all on the next sequential action.
At some point after you've got the plain ordinary sequential actions working, then you can look at how to cancel background tasks. But until the plain sequential stuff works, trying to deal with cancelling is pointless.
As to why uploadDataRequest is failing, there's no way to tell. It's impossible to discern what you're expecting to happen. One red flag I see is the complete lack of error handling, or even error checks. You've also got a class URLRequest whose operation is utterly opaque since you've shown no code for it.