waler
waler
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
I'll read the document first and probably go back to the example you gave, all I understand as of now is there might be multiple threads that read and write the value of counter at the same time, which is why we did not get 10000 as a result.
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
ok wow, thank you so much
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
alright, thank you so much for the help. I think I'll go read more on this topic
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
ok wow, now this makes me worry since my system actually has one more logic where I would need to calculate the algorithm (possibly in the main thread) for choosing a destination floor while the elevator is moving.
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
oh right, because the loop keeps iterating
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
I have also heard of a locking mechanism? Though I do wonder if that helps with anything here
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
yeah, seems like that's the best way there is
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
wow timing is really a headaching thing with multithreading
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
hmmm I see
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
hmmm I see, so the real reason was because of a race condition that was bound to happen, if I maybe did something like making the main thread sleep for a bit after assign a new thread to the threads array, can this avoid the race condition potentially happening?
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
also thank you so much for the fix For the elevatorindex, that was actually a really nice way to get over the pass by reference bit. Also did not know I could avoid constructing a new ThreadStart every iteration.
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
hmm I get a hint that it was using i as a reference too. Although may I ask why is this the case? It's so weird to see a value type be passed by reference even though I didn't specifically ask it to pass by ref
38 replies
CC#
Created by waler on 12/4/2023 in #help
Help with Multithreading
I can of course create each threads manually, but I'm trying to generalise this for case with any amounts of elevators. I would appreciate any other idea recommendations as well.
38 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
ah, I think I have read over an example that used get - set but did not look into it, I'll do some search on this then
13 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
I haven't looked through this, I'll go read about that
13 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
oooh so kind of like defining a local property for the class?
13 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
kekw
13 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
alright, thank you very much. Weird that I overcomplicated something so simple
13 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
hmmm maybe I should have done that
13 replies
CC#
Created by waler on 10/12/2023 in #help
Help with program logic
I did actually, then I thought that seems inconvenience when I need to update multiple attributes...but, now that thought seems silly of me
13 replies