multithreading - c# Thread syncronization problem -


So I see content playing with threads funny .

I have a way that starts the thread and continues with its life and I tried to do the following to keep things safe.

  bool CopyOk1 = false; Bool copyOk2 = False; New thread ((= =) Firstprocess (template 1, riff coke 1)). Start (); New thread ((=) gt; second method (tempList2, referee CopyOk2)). Start (); Var spinner = new spinwight (); While (CopyOk1 ||! CopyOk2) spinner.SpinOnce ();   

Then in both the methods I start with the following

  Private static zero first method (list & gt; temp & gt; temp list, riff bool CopyOk) {var temp = new t [templist.Count]; Templist.CopyTo (temporary); CopyOk = true;   

My intent is to copy the passed list so that I can safely alter and use it within the ASAP to unblock the caller thread.

My problem is that the second method unexpectedly, by formulating the array initialization and copying it to the list per list, by some means, by some means.

These lists are created inside the collar thread and are not actually used. Thread has started, so I have absolutely not considered not why this is happening.

There is no doubt that I am doing something wrong here, but my Nobis Skill will not let me see, any help is appreciated.

Nothing in the code you posted that you are doing something wrong The problem is elsewhere It is a lie - most likely, as the commentators have suggested that the code deposits in 1 / list2. If you are also threading in that form, then maybe you are not waiting to strengthen the index before proceeding with that thread?

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -