Synchronous c# threads on the compiler, and call stack

Synchronous c# threads on the compiler, and call stack
0

#1

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?


#2

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


#3

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();


#4

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.


#5

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.


#6

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?


#7

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.


#8

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.


#9

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


#10

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

Thanks very much!


#11

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.


#12

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


#13

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


#14

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