今天在單線程的時候C# dictionary插入數據,不會出現問題
在多線程的時候出現 System.Collections.Generic.Dictionary`2.Insert System.NullReferenceException: 未將對象引用設置到對象的實例
加一個鎖試試吧
Monitor.Enter(x);
。。。。。
Monitor.Exit(x);
今天在單線程的時候C# dictionary插入數據,不會出現問題
在多線程的時候出現 System.Collections.Generic.Dictionary`2.Insert System.NullReferenceException: 未將對象引用設置到對象的實例
加一個鎖試試吧
Monitor.Enter(x);
。。。。。
Monitor.Exit(x);