Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
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:
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.
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.
 
Thanks to everyone who has been helping me with this issue. It looks like I have come to a solution. Chown...I think in the future you should read the whole thread before you attempt to condescend to those that are posting.

For those of you out there who read this in the future what I did to solve this was the following (back to PhoneyDeveloper's idea):
Code:
-(void)encodeELF:(NSData *)data
{
	//initialize variable and allocate memory
	NSString			*filespace=[[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding];
	NSOperationQueue	*operationQueue=[[NSOperationQueue alloc]init];
	
	virtual_machine_32 *vm = [[virtual_machine_32 alloc]init];

	[self printToScreen:@" Parsing Executable...\n"];

	[operationQueue addOperationWithBlock:^{
		NSDictionary		*loadElfReturn;
		Parameters			*send=[[Parameters alloc]init];
		
		loadElfReturn=[vm loadelf:filespace];
		send.memory=[loadElfReturn objectForKey:@"Memory"];
		send.symbol_table=[loadElfReturn objectForKey:@"SymbolTable"];
		send.entryPoint=[loadElfReturn objectForKey:@"Entry"];

		[vm vm32:send];
		
		vmInstructions=[vm.instructions intValue];
		systemCalls=[vm.systemCalls intValue];
		boincCalls=[vm.boincCalls intValue];
		
		//free memory
		[filespace release];
		[vm release];
		[send release];
		[operationQueue release];
		
		[self performSelectorOnMainThread:@selector(uploadDataRequest) withObject:nil waitUntilDone:NO];

	}];

	[self printToScreen:@" Executing...\n"];	
}
Using the operationQueue with the setOperationWithBlock: allows me to toss a whole bunch of stuff into the background while the main thread puts the text to the screen. As a note URL requests apparently must be done from the main thread so that is why we get the line
Code:
[self performSelectorOnMainThread:@selector(uploadDataRequest) withObject:nil waitUntilDone:NO];

Thank you all.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.