Synchronous c# threads on the compiler, and call stack

Hi,

I learn tutorial on website in unity. here

but I found a problem in TextInput.

void AcceptStringInput(string userInput)
{
    userInput = userInput.ToLower();
    controller.LogStringWithReturn(userInput);

    char[] delimiterCharacters = { ' ' };
    string[] separatedInputWords = userInput.Split(delimiterCharacters);

    for (int i = 0; i < controller.inputActions.Length; i++)
    {
        InputAction inputAction = controller.inputActions[i];
        if (inputAction.keyWord == separatedInputWords[0])
        {
            inputAction.RespondToInput(controller, separatedInputWords);
        }
    }

    InputComplete();

}

how it can make sure inputComplete executed after inputAction.RespondToInput finished.

I know it’s synchronous, but it only make sure inputAction.RespondToInput executed before inputComplete.

Here is the article I read. article

It said that even in synchronous mode, it may be the operations are performed simultaneously.

I also learnt c++, java, javaScript. What happened in those languages?

java is just infamous, but it’s still there

c++ it’s used in all sorts of hardware, but it’s just that other, simpler languages are easier to introduce people to coding

js it’s still being used, it’s just used in conjunction with other front end libraries, or substituted for more powerful languages

What do you mean?

I just confused when the function can get the result of previous function.

in single thread, it can got it.

But how can I know it is single thread or multiple threads on the backgrounds.

Because sometimes I wrote code as the I posted above.

but when InputComplete() running, it did’t get the result of inputAction.RespondToInput();

I was answering you last statement in your original post about what happened to the other languages. Didn’t mean to actually to offer any explanation, sorry.

Though to answer your question of

I don’t think you really need to do anything. From what I can see, AcceptStringInput is added to a listener. Any time that the listener detects an event on inputField.onEndEdit.AddListener, the AcceptStringInput will run. That’s how it knows to run. It seems to me that the event is triggered after the inputField is finished editing (by hitting enter it seems), and therefore will run inputAction because there are multiple entries in InputAction when the event triggers.

Now that I’m reading this closer:
c++ If anything, things were single threaded in microprocessors. You had interrupts which halted the current running code to handle a tidbit of other code and then returned to the main line. However, in C++ based UnReal, no idea. Haven’t really worked with it so I can’t say much.
Java: It’s been so long since I’ve touched Java, but should be similar to C#.
Javascript: I don’t know enough in the case of sync and async calls. I believe if you’re doing an async call to another place, yes, you’d have to have a placeholder and then update after getting the results of the async call.

How do you know if it’s multi or single? That I cannot tell you. I’m leaning toward single, but it may be distributed if it can get away with it.

so, you mean that c++, c#, java will after one function finished then execute the next, Javascript is not sure.

is it what your meaning ?

Do you know any books or website talks about it?

Javascript should do things one at a time, but for certain things like calls to an external website, it’ll perform the get but still continue on (at least in jquery anyways)

Don’t know where I can really point you for more reading. This is just what I’m observing from what I’ve touched.

Thank you very much!
by the way, I just curious about why I confronted the later function can’t get the result of previous function in unity.

I don’t remember the situation, but I pretty sure I saw it a few times.

Idk. I think if you follow the Unity tutorial, it should work. I didn’t have any problem with it.

yes, right now. There is no problem.
I just don’t know why it have problem before.

Thanks very much!

The only time it might fail is if you hit enter without actually typing anything. That is the only possible error I can think of.

it’s not the case, I remember that when I wait a few seconds. Then I can got the result.

Ah okay. Then I have no idea! Glad it works now though.

thanks! I just learnt that C# have thread system by default .

1 Like