Search Unity

Threading with arguments from another class function call

Discussion in 'Scripting' started by Guy_Yome, Oct 9, 2015.

  1. Guy_Yome

    Guy_Yome

    Joined:
    Sep 30, 2014
    Posts:
    13
    So here I have a problem I've been searching for a while to find. I need to start a thread on a function that requires a lot of process. The thing is that this function needs to be called by another class that knows this class reference. Also, it requires 3 arguments. All I've seen in my searches are example of threading but with no arguments. Also, I use c#.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Threading with arguments is identical to threading without them. The code and concept is the same.

    The key is generally that you should only touch each data structure from one thread at a time. The easiest way is to not touch something at all after it's been handed off to another thread and before it's finished. But you can also do a bunch of synhronisation stuff.