Asked — Edited

Multithreading And How It Affects A Revolution Bot

Hi there!

I saw there was recent activity on this board from a customer and DJ - and was linked. I do have a specific question about threads and how the bot might react to a given problem (given I don't have a bot yet - just coding for fun and as concept - but might be a good question before I get ahead of myself).

My question is this. I posted this:

if you watch the video, you'll notice that there was a huge delay while the main executable fetched some JSON from Google. This REST request actually stopped the entire process (ie, if I'd've alt+tabbed out and then back in then the GUI wouldn't have come back until the results were in the textbox).

My question is, what would the bot have done? Would not having sent this request into a separate thread to be worked on in, have completely frozen the robot as well as the C# GUI that I'd hacked? And, if yes or if no, if I do a normal thread the way I already know how to code it (I don't have current examples of 'how /I/ know how to code it' but it's probably hack-y and not standard or even acceptable in a workplace) - how would the bot react differently?

Cheers for now everyone and have fun!

As a giant ps. I threw my pending purchase into my cover letter for a mobile app development / hardware repair / sales position I applied for that's semi-local:

'(...) Even recently I have undertaken the prospect of expanding my knowledge to include the robotics branch of sciences, combining software and hardware into a uniquely interesting result. (...)'


Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!


I don't understand your question, sorry. Are you asking how to multithread something?


Hey! Thanks for being around on the weekend!

Nope, not how to code multithreading itself - I can do that or google how to do that if it doesn't work the way I want it to. I should be more clear.

Basically I'm wondering what a Revolution bot will do if they are running code that I've written and for whatever reason that main executable thread gets suspended. . . for example if I ran a


inside of the code, like the person in the forum post I linked to had run - without using multithreading to make sure that the rest of the application runs while that sleep runs on it's own in a corner - in his question he mentioned it froze his GUI. Would it 'freeze' the robot, making him unable to do anything until that sleep finishes?

my reason for asking is that a piece of code I wrote paused the execution of the main thread while it was fetching information from a RESTful interface.

Thanks again!


It would be helpful if you showed us the code you are having problems with.


There's no problem yet - but I had the link in my original post, here's a pastebin:

the offending code is here:

    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            StreamReader reader = new StreamReader(response.GetResponseStream());

            . . . etc

it just reaches out over the internet to load whichever site I asked it to. During that time it needs to stop for a sec and wait for the response and then parse the response, which then causes the behavior in C# and I'm just wondering what a robot would do if given this code :)


If you're waiting for a response, the robot will continue to do the last thing you told it to. If the last thing it was doing was nothing, then it'll continue doing nothing. Unless you tell it to do something while it's waiting, it won't do anything different then the last time you told it to do something.

For example, if you told the robot to move forward... it will continue to move forward until you tell it to do something else. If there is time between the moving forward and the time it takes to do something else is 30 seconds... then it will continue moving for 30 seconds.

It's like your car. If you're driving down the street moving forward, you will continue to move forward until you turn the steering wheel. If you decide not to turn the steering wheel, then you will continue to move forward for ever. If you decide to turn the steering wheel in your head, but don't actually do it with your hands, your car will not turn. Your car will only turn when the steering wheel has told it to turn.

The same is for your robot. I guess it's 'action' and 'reaction' are reasoning behind causality.

Mostly your question is philosophical and less multithreading :)


:) I guess it was! That painted a great picture of what I'd been asking. Sorry it was so confusing!

Super glad to see you active during non-work hours, by the way.

Cheers for now!